Hello, I hope someone can help, I'd like to create a script to be run from "Main Directory" to move any files three subdirectories below up one level, this needs to be able to use a method of wildcards for directories as there are many constantly changing directories, the "Main Directory" itself is also a variable I just wish to be able to move script to this directory and run from there. there are potentialy other files in other directories that don't want to be moved, to demonstrate...
Main Directory/ Random folder jhi/ Random folder jgy/ Random folder jhi/ files that want to be moved to Random folder jgy (up one level)
Main Directory/ Random folder mnu/ Random folder rts/ Random folder pih/ files that want to be moved to Random folder rts (up one level)
Main Directory/ Random folder aft/ Random folder tfg/ Random folder kjk/ files that want to be moved to Random folder tfg (up one level)
Main Directory/ Random folder kje/ Random folder wth/ Random folder pyt/ files that want to be moved to Random folder wth (up one level)
Thanks in advance to any help you may be able to offer.
Move all files up one directory
Moderator: DosItHelp
Re: Move all files up one directory
If I don't miss something, that should do the trick:
This doesn't move anything yet, it just prints the command lines to the screen. Remove both ECHO and PAUSE if the right files and target folders are displayed.
Steffen
Code: Select all
@echo off
for /d %%a in (*) do for /d %%b in ("%%a\*") do for /d %%c in ("%%b\*") do for %%d in ("%%c\*.*") do ECHO move "%%d" "%%b\"
PAUSE
Steffen
Re: Move all files up one directory
Thanks Steffen, I knew it would be a pretty simple batch, spent hours trying to figure it out to no avail, you've saved me so much time, very much appreciated.