moving folders auotmatically to other folder on server
Moderator: DosItHelp
moving folders auotmatically to other folder on server
i want to create a folder so that whenever i move something into it that should be copied to the another folder on server and get deleted from original folder ... is there any command ?
Re: moving folders auotmatically to other folder on server
This should move everything from a folder to a server, and check around once per minute after each run.
Change the coloured bits and test it first.
@echo off
:loop
for /f "delims=" %%a in ('dir "c:\folder\*.*" /b /a-d') do (
move /y "c:\folder\%%a" "\\server\share\"
)
ping -n 60 localhost >nul
goto :loop
Change the coloured bits and test it first.
@echo off
:loop
for /f "delims=" %%a in ('dir "c:\folder\*.*" /b /a-d') do (
move /y "c:\folder\%%a" "\\server\share\"
)
ping -n 60 localhost >nul
goto :loop
Re: moving folders auotmatically to other folder on server
hello Foxi
its not copying the subfolders of that folder which i made... its copying text files and after copying can the move files or folders get deleted automatically
its not copying the subfolders of that folder which i made... its copying text files and after copying can the move files or folders get deleted automatically
Re: moving folders auotmatically to other folder on server
sorry its deleting the files but solve this its not moving the subfolders
Re: moving folders auotmatically to other folder on server
This should xcopy the entire folder across into a date and time stamped folder, and then delete the files.
Beware: If any files or folders are dropped into the source folder while it is copying then they may or may not be copied - and will be deleted.
Change the coloured bits and test it before use.
@echo off
:loop
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
echo copy has started
xcopy /s/h/e/k/f/c "c:\folder\*.*" "\\server\share\%dt:~0,8%_%dt:~8,6%\"
rd /s /q "c:\folder\"
md "c:\folder\"
echo copy finished
ping -n 60 localhost >nul
goto :loop
Beware: If any files or folders are dropped into the source folder while it is copying then they may or may not be copied - and will be deleted.
Change the coloured bits and test it before use.
@echo off
:loop
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
echo copy has started
xcopy /s/h/e/k/f/c "c:\folder\*.*" "\\server\share\%dt:~0,8%_%dt:~8,6%\"
rd /s /q "c:\folder\"
md "c:\folder\"
echo copy finished
ping -n 60 localhost >nul
goto :loop
Re: moving folders auotmatically to other folder on server
Hello Foxi
i dont want the date and time stamped folder, because in the server folder we identify the folders by our naming convention , i just want the folder moved to the server folder and get deleted from source folder and one more question if we close the executable file will it stop running every 60 sec and one more question is this possible i have 5 drives in each drive there are many folders in that folders i am going to create a folder named DATA in folders where ever i desired which will be our source folder in which we will moving folders, is it possible that only one executable file for each drive. so that we dont have to go to each folder and run the batch file.
i dont want the date and time stamped folder, because in the server folder we identify the folders by our naming convention , i just want the folder moved to the server folder and get deleted from source folder and one more question if we close the executable file will it stop running every 60 sec and one more question is this possible i have 5 drives in each drive there are many folders in that folders i am going to create a folder named DATA in folders where ever i desired which will be our source folder in which we will moving folders, is it possible that only one executable file for each drive. so that we dont have to go to each folder and run the batch file.
Re: moving folders auotmatically to other folder on server
What will you do about folder name and filename collisions, if they are the same on the 5 drives?
Re: moving folders auotmatically to other folder on server
if it is same also they are not going in same folder in server each folders in each drive will be given a separate server folder path
Re: moving folders auotmatically to other folder on server
adill441 wrote:Hello Foxi
just remove the time and date stamp folder creation just i need whatever is posted in source folder should be copied in server folder and tell me that if we close the batch will it be still running or we have minimize it and keep it till our work is done...
Removing the time stamp is simple.
You can close the batch file, as long as it is not copying files at the time.
Re: moving folders auotmatically to other folder on server
OkaY Thanks Foxi for your help please remove that date and time stamp and give me the code
Re: moving folders auotmatically to other folder on server
Try this - I haven't tested it. Increase the 60 to 300 to have it check for new files every 5 minutes.
Code: Select all
@echo off
:loop
echo copy has started
xcopy /s/h/e/k/f/c "c:\folder\*.*" "\\server\share\"
rd /s /q "c:\folder\"
md "c:\folder\"
echo copy has finished
ping -n 60 localhost >nul
goto :loop
Re: moving folders auotmatically to other folder on server
Thank You so much Foxi its working fine