问题
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:
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
)
)
来源:https://stackoverflow.com/questions/29583417/using-batch-to-clean-up-file-names-to-name-full-path