Reputation: 13
I have tens of thousands of *.wav
files spread out across hundreds of folders. I need help to get command line to move all files up one level. The directory structure for all these files are identical, but the names of the folders vary slightly:
Z:\Audio\Level*\story*\VOCAB\*.wav
All files are located in the VOCAB
folders, and I need to move them to the story*
folders:
Z:\Audio\Level*\story*\*.wav
I can do this from command line by running a move command on each individual folder, but is there a way to run it recursively on all files within the entire directory? Can I use a wildcard in the location path?
Notes:
The * in Level* and story* are numbers 01-24.
I'm on Windows XP Professional.
Thanks for any help you can provide!
Upvotes: 1
Views: 4847
Reputation: 21
try something like:
for /r %F in (*.wav) do move %F %~pF\..
refer to for /?
from command prompt as reference (particularly in case I didn't 'code' that quite right...)
I suggest starting it from within \Audio
directory.
Upvotes: 2
Reputation: 1809
Found a similar question in another forum (http://www.computerhope.com/forum/index.php/topic,98046.0/all.html).
Modifying some of their code, here's a batch file script that might do the trick (please try on a small subset before unleashing it on everything):
@echo off
set thisdir=%cd%
for /f "delims=" %%A in ('dir /b /ad') do (
cd /d "%%~dpnA"
for /f "delims=" %%B in ('dir /b /ad') do (
echo Level 2 Directory: %%~dpnB
cd /d "%%~dpnB"
for /f "delims=" %%C in ('dir /b /ad') do (
echo Level 3 Directory: %%~dpnC
cd /d "%%~dpnC"
move *.* ..\
cd ..
rd "%%~dpnC"
)
cd ..
)
cd..
)
cd /d "%thisdir%
Upvotes: 0