简体   繁体   中英

Create new subfolder with same name and move files to the new folder

I need your help to complete a windows batch (.cmd) file to create a new folder based on parent folder name and move some files to the new folder.

(both directory names and/or file names will be always different and may have space chars or dots)

I managed to created the folder based on current dir name but I cant figure how to move the files to the new folder. I'm using this in a button in Total Commander that's is working partially.

I'm not programmer, only have a very basic knowledge of batch. I was searching a lot of examples and trying but I could not find the way. Thanks in advance.

I Have this:

D:\Artist - Album\   <--- current start path
   ├──01-track1.wav
   ├──01-track1.flac
   ├──02-track2.wav
   ├──02-track2.flac

Running this line to successfully create subfolder based on parent name: "Artist - Album (FLAC)"

for %%* in (.) do md "%%~n* (FLAC)"

Results in:

D:\Artist - Album\
   ├───\Artist - Album (FLAC)\   <--- new folder OK!
   ├─01-track1.wav
   ├─01-track1.flac
   ├─02-track2.wav
   ├─02-track2.flac

What I want is move the .flac files inside that new folder like this:

D:\Artist - Album\
   ├───\Artist - Album (FLAC)\   ┐
   │    ├─01-track1.flac         ├ ?
   │    └─02-track2.flac         ┘
   ├─01-track1.wav
   └─02-track2.wav
for %%a in (.) do md "%%~na (FLAC)"&move "*.flac" ".\%%~na (FLAC)\"

& cascades commands.

(untested)

Please don't use symbols as metavariables - only alphas are documented (and presumably supported) and * and many other symbols have a special meaning to batch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM