Using BATCH to clean up file names to name full pa

2019-08-26 13:32发布

All the information is located in a text file. I would like to go from this:

/var/www/xxx/video_folder_1:
New folder
New folder - Copy
New folder - Copy (10)
New folder - Copy (10) - Copy
New folder - Copy (10) - Copy - Copy
New folder - Copy (11)

/var/www/xxx/video_folder_2:
cideo.mp4
sadasd

To this:

/var/www/xxx/video_folder_1/New folder
/var/www/xxx/video_folder_1/New folder - Copy
/var/www/xxx/video_folder_1/New folder - Copy (10)
/var/www/xxx/video_folder_1/New folder - Copy (10) - Copy
/var/www/xxx/video_folder_1/New folder - Copy (10) - Copy - Copy
/var/www/xxx/video_folder_1/New folder - Copy (11)/
/var/www/xxx/video_folder_2/cideo.mp4
/var/www/xxx/video_folder_2/sadasd

To be honest, I have NOT idea how to approach this as this is way beyond my batch skills.

1条回答
狗以群分
2楼-- · 2019-08-26 14:20

Try this:

@echo off
setlocal EnableDelayedExpansion

for /F "delims=" %%a in (test.txt) do (
   set "line=%%a"
   if "!line:~0,1!" equ "/" (
      set "header=%%a"
   ) else (
      echo !header:~0,-1!/%%a
   )
)
查看更多
登录 后发表回答