batch file to copy file
Hello
The code for a batch file
copy folder (my folder name is = my client of the user on the example of .to network username user name of May is user1 so my D ind drive file is user1) from one disk to another copy.
I tested this code, but has not responded.
MD D:\bdc94attrib -r -h -s D:\bdc94\*.*xcopy "d:\%username%\*.*" d:\bdc94 /Q /Y /R /S
tanks
Hello James,.
Thanks for posting your question on the Microsoft community.
I appreciate your time and patience.
This question fits better for Windows developers on MSDN forums.
I suggest you post your question on the MSDN forums for assistance by other developers.
MSDN forum
https://social.msdn.Microsoft.com/forums/Windowsdesktop/en-us/home?category=windowsdesktopdev
Thank you
Tags: Windows
Similar Questions
-
How can batch files - I copy files from subfolders
II have a directory with several folders that contain pictures, documents, etc... I need a batch file which will look through all these aand only copy files .doc to a specific folder. Now there are hundreds of these files that need to be addressed through, so I really don't want og manually, would be nice if someone could help me here
Duplicate file names... If you assume that there is not
-> These assumptions are generally bad.
is it easy to code?
-> Easy to code but hard to understand, unless you're an expert. Notice that the script fails when it encounters some "poison characters" such as brackets or double quotes. If you have one of these in your file names or folder, then a different approach is required.
off @echo
Set SourceFolder = C:\Users\JohnDoe
Define TargetFolder = D:\MyDocs
for /F "delims =" % in ('dir /s /b /ad "% SourceFolder%\*.*" ') do)
If there are some "%%a\*.doc" xcopy.exe/y "%%a\*.doc*" "% TargetFolder%\". »
) -
Copy files from specific date ranges in a Batch file
I'm trying to copy files from a folder with many subfolders to another drive using a batch file. I want to copy the files in the date ranges specific (e.g. 01/01/2016 to 03/31/2016).
I use this with Xcopy command:
xcopy "C:\Users\John\Pictures\*.*" F:\BACKUP\Pictures/s/h/i/y
It works, but I want to send groups of files by date for the different destination folders. I'm having a problem by specifying a date range in the command line.
Is this possible with xcopy or robocopy? Does anyone know how to list the date rang in the command?
Thankss in advance,
John
Hello
Please contact Microsoft Community.
I understand you wanted to know about the files and folders by using the copy command line.
I suggest you go through the links below:
Refer to the suggestion given by SpiritX MS MVP replied on 14 August 2010 and check if that helps:
If the still the problem persists, I suggest you to post your query on TechNet:
Feel free to write us again with the status of the issue.
-
batch file to copy the file with the extension of the date - does not work in Windows 7
Under XP, I got a batch file to copy files daily and rename them with the date, as:
Project_Tracker_Copy.mdb
TO
Project_Tracker_Copy_2012_01_17.mdb - it would make the current format YYYY_MM_DD day
next day, through Planner, he would run the batch and I'd end up with
Project_Tracker_Copy_2012_01_18
Here is the key part of the DOS command:
Ren S:\archive_2012\Project_Tracker_Copy.mdb Project_Tracker_Copy_%date:~6,4%_%date:~0,2%_%date:~3,2%.mdb
A batch file that runs hidden in Task Scheduler. [Task Scheduler starts the vbs & the vbs starts the batch file.
This example shows how run the batch BackupCoreFiles.bat - the only point the vbs to packaging is so he can run hidden like Task Scheduler it would be otherwise in the default command window & that can be a distraction, if you work on something else at the time.
Set WshShell = CreateObject ("WScript.Shell")
Chr (34) WshShell.Run & "C:\Program Files (x 86) \Backup" & Chr (34), 0
Set WshShell = NothingThe well-informed person who first posted this code was Ramesh Srinivasan how to run . BAT files invisible
-
I am running Windows 7 and I have a batch file to copy files from 1 computer to another. It works fine alone, but when I put it to run in the Task Scheduler it shows it ends successfully, but nothing is happening. None of the files are copied, and the control box does not appear. Any ideas?
Run a batch file in Task Scheduler
Hello ITGIRL17,
Thanks for posting on the Microsoft answers Forum.
Configure your task under your administrator account.
Then go to the folder with the batch file and ADD on control for the folder administrator permissions and each of the files in batches.
If the batch files write data, then the target for the task should ALSO have all explicit permissions.
Now try to run the Task Scheduler task.Also check the information from the following link and look specifically at Brian Vandemark Sommaire steps on 2 September.
http://social.technet.Microsoft.com/forums/en/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbeI hope that this information will help resolve your batch file does not problem.
Sincerely, Marilyn
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think -
Hello
NETFIX.bat an 'L' of the command file
Not important, but most of what follows is true. It's just a HOW2 simplified for initial review. It is not a definitive guide, don't forget...
Never believe anything, everything you hear, and only about half of what you see; in particular within this document.
DISCLAIMER: This is my own personal scribbles used to create a batch file to reduce the typing needed to use some of the commands in my network A2Z nonsense & applying a low degree of automation. Now, I'm not able to ensure the effectiveness of the controls on my system, because it isn't really broken. So use you it at your own risk, your levels of configuration & special access is certain to be different to mine.
It was written using Notepad and is the plain text that can be scrutinized, edition, amended and implemented by almost everyone.
@ECHO THIS MIGHT HELP TO REPAIR/RECTIFY @ECHO SOME SIMPLE NETWORK DIFFICULTIES. @ECHO based on work by @ECHO Kevin Arrows, Jim Eshelman et al. @ECHO .................................... @ECHO. @ECHO THE RESULTS MAY VARY ACCORDING TO @ECHO YOUR CONFIGURATION AND USER LEVEL @ECHO A RESTART SHOULD BE MADE AFTER @ECHO THE RUNNING OF THE ABOVE TESTS @ECHO .................................... :MENU @ECHO. @ECHO .................................... @ECHO. @ECHO TYPE IN THE RELEVANT MENU NUMBER @ECHO. @ECHO .................................... @ECHO. @ECHO 0 - GET_MAC Obtain MAC address(es) @ECHO 1 - GET_IPs Lists all IP addresses @ECHO 2 - ADDRESS Force/Renew IP address @ECHO 3 - DNS_FIX Flush and Register DNS @ECHO 4 - WINSOCK Reset to remove errors @ECHO 5 - IPV4_V6 Reset to remove errors @ECHO 6 - PING_LO Ping tests to Loopback @ECHO 7 - NETSTAT All Network Statistics @ECHO 8 - SYS_SUM System Summary Windows @ECHO 9 - EXITNOW Close this Command Box @ECHO. @ECHO .................................... @ECHO OFF SET /P M= Choose from 0 - 9, then press ENTER: IF %M%==0 GOTO GET_MAC IF %M%==1 GOTO GET_IPs IF %M%==2 GOTO ADDRESS IF %M%==3 GOTO DNS_FIX IF %M%==4 GOTO WINSOCK IF %M%==5 GOTO IPV4_V6 IF %M%==6 GOTO PING_LO IF %M%==7 GOTO NETSTAT IF %M%==8 GOTO SYS_SUM IF %M%==9 GOTO EXITNOW :: :GET_MAC GETMAC GOTO MENU :: :GET_IPs ipconfig GOTO MENU :: :ADDRESS ipconfig /release ipconfig /renew :: :DNS_FIX ipconfig /flushdns Ipconfig /registerdns GOTO MENU :: :WINSOCK netsh winsock reset catalog GOTO MENU :: :IPV4_V6 netsh int ipv4 reset reset.log netsh int ipv6 reset reset.log GOTO MENU :: :PING_LO ping 127.0.0.1 GOTO MENU :: :NETSTAT netstat -e -s GOTO MENU :: :SYS_SUM msinfo32 GOTO MENU :: :EXITNOW EXIT
Hello
HOW?
Well make HP machines, I'm a. I wrote the code on mine, I ran and tweaked. Since it is part of the operating system provided with my camera, it must be relevant.
So when someone asks what is/where or how to find MAC address, he covered (0 GETMAC).
If someone reports their Wi - Fi dropping out after a short time a possible solution in the list (4 WINSOCK
You want to know your IP... (1 GET IPs)
Trial material basis, ping your loopback (6 PING_LO).
etc etc.
Then as a sticky it could potentially help solve quite a few queries. In the same way as The Great Deku Tree posted a sticky on the "Common corrects problems of wireless connectivity", to get ahead of the game by offering something that the OP can try for themselves.
-
The problem: you have two directories structures identical, a source and a target. (Let's say \\srchost\srcfolder and c:\destfolder.) The goal: using a batch file in Windows XP, browse to the source folders and add all files to the destination tree that do not already exist there. We are not concerned with the dates, only if the file exists.
The Replace command has a parameter /a which will do that to a single file, but it will not browse.
Using the command ForFiles to browse directories and pass them to replace does not work because it does not support UNC paths.
Winds with the command For being... infernal. Here is some of the best I have to this day, in the form of a batch file called with the paths of the src and dest as parameters:
Set srcpath = % ~ f1
the value destpath = % ~ f2
for/r % srcpath % (.) DO)
Set tmpsrc = %% ~ fi
Set tmpdest = % destpath
otherwise! tmpsrc! is % srcpath % set tmpdest = call! tmpdest! tmpsrc: % % = srcpath!
replace/a! tmpsrc! \ *. * « ! tmpdest! »
)I think we can all agree this is really obnoxious, especially because it works only if you start the shell with the V switch: WE.
This turns into an unhealthy obsession for me. I wanted a simple batch file solution to this since, oh, around 1990. Surely, there must be a better way! Can someone enlighten me?
And just at the head of some obvious answers:
1. No, I don't have the option to install just
. 2. do not forget that it must work with the UNC paths, so ForFiles is out.
Thank you for your ideas! I really sleep better if there is a healthy way to run this seemlingly simple task.
-Roy
Robocopy with . /XF looks like a possibility.
"Roy Feague" wrote in the new message: * e-mail address is removed from the privacy... *
The problem: you have two directories structures identical, a source and a target. (Let's say \\srchost\srcfolder and c:\destfolder.) The goal: using a batch file in Windows XP, browse to the source folders and add all files to the destination tree that do not already exist there. We are not concerned with the dates, only if the file exists.
The Replace command has a parameter /a which will do that to a single file, but it will not browse.
Using the command ForFiles to browse directories and pass them to replace does not work because it does not support UNC paths.
Winds with the command For being... infernal. Here is some of the best I have to this day, in the form of a batch file called with the paths of the src and dest as parameters:
Set srcpath = % ~ f1
the value destpath = % ~ f2
for/r % srcpath % (.) DO)
Set tmpsrc = %% ~ fi
Set tmpdest = % destpath
otherwise! tmpsrc! is % srcpath % set tmpdest = call! tmpdest! tmpsrc: % % = srcpath!
replace/a! tmpsrc! \ *. * « ! tmpdest! »
)
I think we can all agree this is really obnoxious, especially because it works only if you start the shell with the V switch: WE.This turns into an unhealthy obsession for me. I wanted a simple batch file solution to this since, oh, around 1990. Surely, there must be a better way! Can someone enlighten me?
And just at the head of some obvious answers:
1. No, I don't have the option to install just
.
2. do not forget that it must work with the UNC paths, so ForFiles is out.
Thank you for your ideas! I really sleep better if there is a healthy way to run this seemlingly simple task.
-Roy -
HOW to run a batch file in BACK 6.22?
I wrote a batch file that works fine in the Windows command prompt, but I would like to be able to run after POST in the BACK. I copied my code AUTOEXEC. BAT file that runs automatically; However sometimes with syntax errors when it reaches the call control and the rest.
echo. This script is counting the # of POSTs. echo. The POST # value is saved in TEST.txt. echo. call:myPOSTTest for /f "tokens=* delims=" %%x in (A:\TEST.txt) do echo POST# %%x echo. &pause&goto:eof ::-------------------------------------------------------- ::-- Function section starts below here ::-------------------------------------------------------- :myPOSTTest - here starts my function identified by its label set var=0 if EXIST A:\TEST.txt ( for /f %%x in (A:\TEST.txt) do (set /a var=%%x+1) ) echo %var% >> A:\TEST.txt goto END :END
Thank you
Hello
Many of us being volunteers do not have the expertise to help. Refer the question to the TechNet Script Center.
-
Flashing batch file returns the control too fast
Hi I have a frustrating problem with a simple batch file that I am running on a W2003 server. For simplicity, it did something like this:
copy a b
call runprog.exe
If errorlevel 0 goto done
echo "error".
output
: fact
echo 'ok '.This has been working for a long time, suddenly and only on 1 times out of 10, while it just started running runprog.exe, control is returned in the batch file and it goes to the error condition. On the other 9 times of 10, she does not return control until runprog.exe has finished (as expected).
I reloaded runprog and tried a new copy of c:\windows\system32\cmd.exe. I also tried runprog.exe without the call - the same results.My conclusion is that something underlying in windows is damaged and he needs fixing with SFC or a recharge, but grateful for any ideas who would not so much here
Thank you very much
Hello
The question you posted would be better suited to the TechNet community. Please visit the link below to find a community that will provide the support you want.
http://TechNet.Microsoft.com/en-us/WindowsServer/bb512919.aspx
Hope this information is useful.
-
I used my memory limited programming back to create a simple series of batch files to back up the important data on 2 separate PC [a running XP Home, the other XP Professional] their respective external hard drives. For this I used the XCOPY command more switches as shown on different help sites. The results seem to have been successful. With the exception of the XP Home PC, where I created the following command to copy the contents of my programs folder
c:xcopy "c:\Program Files\ *.» ' ' * J:\DellPrograms\*.* /CDYSWFHURpauseWith the appropriate changes to the details by car this command worked OK on XP Prof. machine On the XP Home, similar batch files machine worked for pure data files. But I can't understand why when the execution of the file above on XP Home the DOS window opens - as it should - but when I tap a button to continue the window closes immediately without anything happening. I am aware that reinstalling a program isn't as simple or the same copy of a piece of text, but that shouldn't stop backup me original exe files. I've fiddled about with some of the switches, but without apparent effect. All the batch files are stored in the folder of programs with links to the desktop for ease of use, but it doesn't make a difference which way I click on it (as I expect). I am running out of ideas, I hope someone will have a brainwave.Hello
The question you have posted is better suited for the MSDN forums. You can post the question to the following link for assistance.
http://social.msdn.Microsoft.com/search/en-us/?refinement=112&query=DOS%20Xcopy -
LEARNING OF BATCH FILES AND WINDOWS CANNOT FIND ' C:\DOCUMENTS'__
Technical info: Windows XP Pro SP 2. Microsft Office home and Student 2007. AVG Free 9.0.
Hello
I am trying to learn the basics of Batch files and am confused right now. I can get a. BAT file to produce a BACK screen and play with some commands, but when I try to get a. BAT file to open a MS Word 07 Doc I get the following message
Windows cannot find 'C:\Documents '. It stops at Documents. When infact the entire address would include Documents\testdoc or something else. I use Notepad to write the. BAT files.
If I go into the file target itself and copy and paste the address in XP search utility, it locates the file (with a full name), instantly. But if I do the same copy and paste, paste the address directly in. BAT file for example: C:\windows, DEPARTURE etc etc... It is just straight up with the above mentioned error message.
All advice forge kindly appreciated. My ultimate goal is to learn how to create a Batch file that will erase the files in different directories about five or six on the click of a button.
Thanks Mick.
I'm not an expert in writing .bat files. If no one else is here, you should post on the MSDN forums or there may be a group of newsgroups for .bat file writing.
http://social.msdn.Microsoft.com/forums/en-us/categories
I'm sorry that I wasn't able to help you.
MS - MVP - Elephant Boy computers - don't panic!
-
Automatic execution of the batch file at the connection of the USB drive
I created a batch file that checks the drive e. the presence of a specific file, and if there, copy it to a location on the hard drive. (Drive E is where all USB drives see the place through my window of Windows Explorer.) I would like to set up my computer so that this batch file is executed whenever such a device is plugged into the USB port. How can I accomplish that?
Otherwise, is it possible to incorporate the Attaché-USB-player status in the batch file itself and just leave that batch file running at any time? I used "IF EXISTS E:\*.*", but that is not do me much good, because I have to keep control of this condition again and again, and eventually the batch file gets tired of the audit and said that the drive does not exist.
Hello
You can ask your question on the TechNet forums for batch files.
http://social.technet.Microsoft.com/forums/en-us/category/windowsvistaitpro
-
Run a Task Scheduler batch file not working
I have I have a batch copy file and rename it to a file. It works fine when double click on it. I set up to run on Task Scheduler using the wizard of Basic Actions. To test the method, I did a simple batch file that displays the date and time and stored in the same folder as my desired batch file. The Scheduler runs the simple bat very well. When I try to launch the bat copy/rename file, it doesn't do anything, but I do not see the flash blue and see that the planner lists the task completed successfully.
Per a suggestion on this site tried to change the setting to "use if the user is logged in or not." When I click on the box, I get a few indecipherable message on restrictions and password empty. It is a single-user computer (w7 64-bit), and as far as I know, is free of passwords and restrictions... Any help much appreciated, I have no hair left to tear.
Hello
The question you posted would be better suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums.
http://social.msdn.Microsoft.com/forums/en-us/category/iedevelopment
It will be useful.
-
Should I have the administrator account to run the batch file?
When I log in as administrator, I run after the file of commands without any problem, but
When I login as a user, I can't run after the batch file, the changeover of the authority.
I would like to know if I need to log in as an administrator to run this batch file or not,
Can I use different accounts group? and always perform this task.
Does anyone have any suggestions?
Thanks in advance for your suggestions :>off @echo
echo copy C: d:RoboCopy C:\ /MIR R:1 /W:1 D:\
ECHO doneHello
To respond to your request, you must enter the administrator password to access this command file.
Instructions for Windows 7
In order to run as administrator, create a shortcut to the batch file.
1. right click on the batch file, then click on copy
2. navigate to the location where you the shortcut
3. right click on the background of the directory
4. select Paste shortcut
Then, you can set the shortcut to run as Administrator:
1. right click on the shortcut
2. Select Properties
3. in the shortcut tab, click Advanced
4. check the box "Run as Administrator"
5. click on OK, OK
Now when you double-click the shortcut it will ask for confirmation UAC and then run as an administrator (which as I said above is different than running under an account in the administrator group)
I hope this helps. -
How would you on the use of the command prompt to create a text file, fill in the data of your command prompt into the text file and save this information to a user's desktop is currently connected? I find that in my business, I am often required to copy a lot of data that are just easier to collect from the command prompt and I would write a batch file to do this for me I would just say to users by e-mail access on a share of business files. As for example. Let's say that the content of my batch file has something like this:
echo offipconfig/allpause%ComputerName%pauseoutputYou get the idea. I know that you could use other means to obtain some of this information, but the idea is that I can automate this process so that a user has to do only execute the batch, and then e-mail the .txt document saved on their desktop for me and delete the batch.Thanks for any response.-ITNewBWhoAmI > %USERPROFILE%\Desktop\IPConfigResults.txt
ipconfig/all > %USERPROFILE%\Desktop\IPConfigResults.txt
SystemInfo > %USERPROFILE%\Desktop\IPConfigResults.txt
The > adds the current results to the file created initially using the > redirection.
I don't know what you intend with % ComputerName % however, it's an environmental no variable not an order so just generates an error
Maybe you are looking for
-
Error on starting of my Compaq Presario CQ57-339WM error on the box that says
I get an error when I boot. Said HPQWUTILS. EXE = No disk there is no disc in the drive. Please insert a disk into the drive. then there \device\hard disc 1\ DR1, the bottom row says Cancel try again continue everything in boxes. If I hit Try again 5
-
The interface OCR training manual
I need to know the different options and their uses in the interface of OCR training as a format of image (in terms of how it determines the recognition), bi modal inspection, precision of speed etc... Can someone help me...
-
When I try to install one of my (10-15 years) old computer games, I get a message saying "ntvdm.exe is not working" and then the application closes without installing. I have a Vista 32 bit. Through my research, I learned that ntvdm is, just, I was n
-
Files found: WIPETEMP1 with 246,1 GB
Hello My system: Dell Dimension 9200; Windows XP SP3 Defragmentation of the race, I discovered a very large amount of defragmentation that defrag does not. I was surprised to find 306.8 GB of used space on my hard drive Go 465,8. I expected to see on
-
Microsoft Wireless 3000 v2.0 keyboard
@ key is of type 'when using SHIFT @ key. The only way to get is to press the "Shift" keys. The CD was not provided with the English UK version can't find software on the microsoft for English UK wewbsite. Is there a solution to fix this problem? Can