How to copy a folder with the given input
Moderator: DosItHelp
-
- Posts: 5
- Joined: 19 Apr 2012 07:39
How to copy a folder with the given input
Hello All,
I am new here .I am struggling to find a solution.
I need a batch script to copy a folder which is in the form XXXXX_YYYYYYYY
Eg: i want to copy folder 2011.50.00++22.00_2011-11-23_6-08-43_PM to another folder .For this i want to give input as 2011.50.00++22.00 which is unique .
I have written a batch file but its not copying the folder.
ECHO off
cls
SET /P RN=enter release number eg : 2012.20.00++22.01 :
ECHO %RN%
d:
cd D:\backup\PUSHED
XCOPY %RN%* \\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\ /S
%SystemRoot%\explorer.exe "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\ "
pause
ECHO ON
------------------------------------------------------------------
the folder i wanna copy will be in D:\backup\PUSHED
I am new here .I am struggling to find a solution.
I need a batch script to copy a folder which is in the form XXXXX_YYYYYYYY
Eg: i want to copy folder 2011.50.00++22.00_2011-11-23_6-08-43_PM to another folder .For this i want to give input as 2011.50.00++22.00 which is unique .
I have written a batch file but its not copying the folder.
ECHO off
cls
SET /P RN=enter release number eg : 2012.20.00++22.01 :
ECHO %RN%
d:
cd D:\backup\PUSHED
XCOPY %RN%* \\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\ /S
%SystemRoot%\explorer.exe "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\ "
pause
ECHO ON
------------------------------------------------------------------
the folder i wanna copy will be in D:\backup\PUSHED
Re: How to copy a folder with the given input
Untested:
With some extra code you can automate the copy by getting the folder name - if there is the one folder in the directory or you can specify the folder in a DIR command.
Code: Select all
@ECHO off
cls
set "RN="
SET /P "RN=enter release number eg : 2012.20.00++22.01 :"
ECHO %RN%
pushd "D:\backup\PUSHED"
XCOPY "%RN%\*.*" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\" /S
"%SystemRoot%\explorer.exe" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\"
popd
pause
With some extra code you can automate the copy by getting the folder name - if there is the one folder in the directory or you can specify the folder in a DIR command.
-
- Posts: 5
- Joined: 19 Apr 2012 07:39
Re: How to copy a folder with the given input
Hi
I dint solve my problem
what is got from ur code is like it will copy the items which are after the folder %RN%
but %RN% is not the entire folder name.
for ex 2012.20.30_rhdhkdn is the folder i wanna give input as 2012.20.30 and thescript should copy the folder whose folder name starts with 2012.20.30 ie 2012.20.30_rhdhkdn to the destination folder
I dint solve my problem

what is got from ur code is like it will copy the items which are after the folder %RN%
but %RN% is not the entire folder name.
for ex 2012.20.30_rhdhkdn is the folder i wanna give input as 2012.20.30 and thescript should copy the folder whose folder name starts with 2012.20.30 ie 2012.20.30_rhdhkdn to the destination folder
Re: How to copy a folder with the given input
This should copy the folder.
Code: Select all
@echo off
cls
set "RN="
SET /P "RN=enter release number eg : 2012.20.00++22.01 :"
pushd "D:\backup\PUSHED"
for /f "delims=" %%a in ('dir "%rn%*" /b /ad') do (
echo copying "%%a"
XCOPY "%%a\*.*" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\" /S
)
popd
"%SystemRoot%\explorer.exe" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\"
pause
-
- Posts: 5
- Joined: 19 Apr 2012 07:39
Re: How to copy a folder with the given input
I tested the code in my local laptop.
enter release number eg : 2012.20.00++22.01 :2012.20.00++22.00
copying "2012.20.00++22.00_yyjdkd"
Overwrite C:\test3\1\New Text Document.txt (Yes/No/All)? y
2012.20.00++22.00_yyjdkd\1\New Text Document.txt
1 File(s) copied
Press any key to continue . . .
C:\Users\velumula\Desktop>
Its copying if the name given as a ipnput is a file .If its a folder its not copying to destination folder.
enter release number eg : 2012.20.00++22.01 :2012.20.00++22.00
copying "2012.20.00++22.00_yyjdkd"
Overwrite C:\test3\1\New Text Document.txt (Yes/No/All)? y
2012.20.00++22.00_yyjdkd\1\New Text Document.txt
1 File(s) copied
Press any key to continue . . .
C:\Users\velumula\Desktop>
Its copying if the name given as a ipnput is a file .If its a folder its not copying to destination folder.
-
- Posts: 5
- Joined: 19 Apr 2012 07:39
Re: How to copy a folder with the given input
@echo off
cls
set "RN="
SET /P "RN=enter release number eg : 2012.20.00++22.01 :"
pushd "C:\test1"
for /f "delims=" %%a in ('dir "%rn%*" /b /ad') do (
echo copying "%%a"
XCOPY "%%a" "C:\test3\" /T /E
)
popd
REM "%SystemRoot%\explorer.exe" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\"
pause
WHEN I USE /T /E its copying subfolders in the input fiolder to destination.I need even the folder to copy to destination with subfolders.
cls
set "RN="
SET /P "RN=enter release number eg : 2012.20.00++22.01 :"
pushd "C:\test1"
for /f "delims=" %%a in ('dir "%rn%*" /b /ad') do (
echo copying "%%a"
XCOPY "%%a" "C:\test3\" /T /E
)
popd
REM "%SystemRoot%\explorer.exe" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\"
pause
WHEN I USE /T /E its copying subfolders in the input fiolder to destination.I need even the folder to copy to destination with subfolders.
Re: How to copy a folder with the given input
I'm not sure what you are after. This should only copy that folder if the name is unique.
This should include the folder name in the target folder.
This should include the folder name in the target folder.
Code: Select all
@echo off
cls
set "RN="
SET /P "RN=enter release number eg : 2012.20.00++22.01 :"
pushd "D:\backup\PUSHED"
for /f "delims=" %%a in ('dir "%rn%*" /b /ad') do (
echo copying "%%a"
XCOPY "%%a\*.*" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\%%a\" /S/H/E/K/F/C/R/Y
)
popd
"%SystemRoot%\explorer.exe" "\\r1mseac02\d$\sea77\siebsrvr\LOGARCHIVE\"
pause
-
- Posts: 5
- Joined: 19 Apr 2012 07:39
Re: How to copy a folder with the given input
while tryn in my local i dint give %%a at the end of destination folder ... now i m successful in copying..thanks mate 
