开发者

how to create a joint list of files in a 2 folders

开发者 https://www.devze.com 2022-12-07 21:31 出处:网络
BACKGROUND I\'m trying to create a [joint] list of (just) the file names from two different folders, namely FULL_REMOTE_DIR and FULL_LOCAL_DIR

BACKGROUND

I'm trying to create a [joint] list of (just) the file names from two different folders, namely FULL_REMOTE_DIR and FULL_LOCAL_DIR

CODE

@echo off
SETLOCAL enabledelayedexpansion
TITLE Demo Mode
ECHO small script to showcase
ECHO how to iterate folders
SET mypath=%cd%
SET "remote_dir=\remote\*"
SET "local_dir=\local\*"
SET "other_dir=\other\*"

SET "FULL_REMOTE_DIR=%mypath%%remote_dir%"
SET "FULL_LOCAL_DIR=%mypath%%local_dir%"
SET "FULL_OTHER_DIR=%mypath%%other_dir%"

ECHO REMOTE DIR:
FOR %%a IN ("%FULL_REMOTE_DIR%") DO (
   SET REMOTE_DIR_LIST=%%a
   ECHO %%a)

ECHO LOCAL DIR: 
FOR %%a IN ("%FULL_LOCAL_DIR%") DO ECHO %%a

ECHO O开发者_运维问答THER DIR: 
FOR %%a IN ("%FULL_OTHER_DIR%") DO ECHO %%a

QUESTION

How can I create a list of files that are in FULL_REMOTE_DIR and FULL_LOCAL_DIR


Try this:

SETLOCAL EnableDelayedExpansion
cd /D %~dp0
set _filelist=,
for /f "delims=|" %%f in ('dir FULL_REMOTE_DIR_PATH  /b %CD%') do (
set "_filelist=!_filelist!,%%f"
)
set _filelist=%_filelist:,,=%
echo %_filelist%

You need to run it from the FULL_LOCAL_DIR, it should create a list of FULL_LOCAL_DIR + FULL_REMOTE_DIR.

0

精彩评论

暂无评论...
验证码 换一张
取 消