1.

Solve : Need to move files and folders up one level.?

Answer»

Hi.
I need to move all folders, except one, up a level as outlined below.
Code: [Select]1
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder (2)
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder (3)
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder (4)
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder (5)
U:\_M_E_D_I_A_S_\t_e_s_t\incoming\New folder (6)

2
U:\_M_E_D_I_A_S_\t_e_s_t\incoming
U:\_M_E_D_I_A_S_\t_e_s_t\New folder
U:\_M_E_D_I_A_S_\t_e_s_t\New folder (2)
U:\_M_E_D_I_A_S_\t_e_s_t\New folder (3)
U:\_M_E_D_I_A_S_\t_e_s_t\New folder (4)
U:\_M_E_D_I_A_S_\t_e_s_t\New folder (5)
U:\_M_E_D_I_A_S_\t_e_s_t\New folder (6)
If any one can start me of with a batch that's a bit more elaborate than...
Code: [Select]echo off
move U:\_M_E_D_I_A_S_\t_e_s_t\incoming\* U:\_M_E_D_I_A_S_\t_e_s_t\*
I would be eternally grateful. Please clarify: you want to create a new (EMPTY?) folder \incoming (or is it already created?) and then:

move the contents of \New Folder into \incoming
move the contents of \New Folder (2) into \New Folder

[...]

move the contents of \New Folder (6) into \New Folder (5) LEAVING \New Folder (6) empty

Is that correct?

Sorry for not making it clear,
I have edited a bit in OP to help, 1, is how it is now and 2, is how i would like it to be be; so move all folders out of "incoming" BACK up into "t_e_s_t" and have them not exist in incoming, but incoming has to remain... Hope you can see my screen captures...

This is before?



And this is after?




The before is correct as is the after, the only difference would be that the folders that are New Folder etc. could be called anything...At the command prompt:

Code: [Select]cd /d "U:\_M_E_D_I_A_S_\t_e_s_t\incoming" & for /f "delims=" %F in ('dir /b /ad') do move "%F" "U:\_M_E_D_I_A_S_\t_e_s_t"
In a batch script:

Code: [Select]cd /d "U:\_M_E_D_I_A_S_\t_e_s_t\incoming" & for /f "delims=" %%F in ('dir /b /ad') do move "%%F" "U:\_M_E_D_I_A_S_\t_e_s_t"Thanks that did the trick.More general batch file; you could save it on your path somewhere; or else save it in a folder and open a command window there.

Suppose you called it movefolders.bat, syntax would be (example):

movefolders "U:\_M_E_D_I_A_S_\t_e_s_t\incoming" "U:\_M_E_D_I_A_S_\t_e_s_t"

remember to provide full folder paths and use quote marks.

Code: [Select]echo off
set fromfolder=%1
set   tofolder=%2
if "%~1"=="" Echo Error! No folders specified & GOTO end
if "%~2"=="" Echo Error! Destination folder not supplied & goto end
If not exist %1 Echo Error! source folder %1 not found & goto end
If not exist %2 Echo Error! Destination folder %2 not found & goto end
Echo Move folders
echo From: %1
echo To:   %2
cd /d %fromfolder%
for /f "delims=" %%F in ('dir /b /ad') do (
echo Moving folder: %%~dpnF
move "%%F" %tofolder%
)
:end
pause



Discussion

No Comment Found