I have tried to copy the file the file structure from an old disc to a new one without copying the files. I have used the command xcopy E:\Richard\Documents C:\Users\Documents /T /E /Q and got the question whether C:\Users\Documents is a file or a directory, answered "directory" and got the answer Access denied. Why? Is it something with the attributes of C?
Can I improve the command in some way?
Something outsida the command that I should do?
Related
Probably there is a better approach to fix what I am trying to do. I have a folder with pictures that I want to copy to another folder renaming them.
Basically, I have a list of all the 80K files of the file name they have, and what is the new name that they should have. There is no fixed pattern to rename the files. What I’ve been doing is using Excel to find the path and current file name and then renaming the files checking the new file name in a SQL database.
Basically, for every file I form a XCOPY line then I paste them on powershell.
echo F|xcopy /s /q /y /f "file path" "renamed file path"
My problem is that for some reason powershell stops processing the xcopy lines after approximately 4K files. I already tried running this as a BAT with these lines for each file.
xcopy /s /q /y /f "file path" "renamed file path *" with an asterisk at end to avoid the question if it’s a file or a folder. But it stops processing after 2K files.
I know that robocopy is better than xcopy but I need to rename each file, and there is not a clear pattern in the renaming, I don’t know how to do a robocopy each file and then rename each file, but that should be even worse no?
Also, the server has a good SSD and its only processing 1 xcopy line per each second, should be a lot faster. The .jpg files are small (˜200Kb).
Any ideas are appreciated.
Regards,
Tiago
I have .bat file like this:
xcopy "C:\sourcepath\sourcefoldername" "C:\resultpath\sourcefoldername" /E
It copied sourcefoldername from C:\sourcepath to C:\resultpath. However, when I run it, if there's already C:\resultpath\sourcefoldername, it asks me if I want to replace all of its contents (I need to enter A). If there's no C:\resultpath\sourcefoldername it asks me if sourcefoldername is a file or directory (I need to enter D).
Is there a way to include answers in the code so that no input from me would be required?
The "\" character at the end of the destination directory tell to xcopy that the destination is a directory (an then xcopy don't ask you).
The /Y switch tell to xcopy to override the file without ask for a confirmation.
xcopy "C:\sourcepath\sourcefoldername" "C:\resultpath\sourcefoldername\" /E /Y
I use this command in order to copy all .ini files (with recursion):
xcopy c:\folder1\folder1A\*.ini c:\mybackup /sy It doesn't copy any file.
There exist desktop.ini files (including comments) within folders and subfolders of folder1A that I want to get a copy of with recursion.
I have tried running CMD as administrator, but it tells 0 File(s) copied. How could I get this to work?
Add the /h option:
/H Copies hidden and system files also. (more info)
This works:
xcopy c:\folder1\folder1A\*.ini c:\mybackup /syh
Thanks to Marged's comment mentioning this question.
Currently looking to copy and rename a file from a C:Drive source to a G:Drive destination by using a batch file. Currently have the following code:
robocopy C:\Users\abronk04\Desktop\Test G:\Users\abronk04\Desktop\Backup /e /purge
ren G:\Users\abronk04\Desktop\Backup accessbackup.jpg backup.jpg
The file will successfully copy, but there is no rename. Do I need to specify a file I am looking to rename? My batch file will copy an entire folder to another destination, unsure if that is the problem here...
I think you ren syntax is not correct.
Maybe try the following after copying the directory
pushd G:\Users\abronk04\Desktop\Backup
ren accessbackup.jpg backup.jpg
popd
This way you will temporarily change your working directory to the sink-path and then change it back
I'd like to move my program files and user documents from C:\Windows.old to C:\, completely replacing what's currently in C:. The old and new OSs on my computer are both windows 10, I just had to make a clean install because I couldn't get it to start after a restoration that went wrong. How can I do this operation using the command prompt at windows startup? Is there a command to do this : move, merge folders, replace files with the same name?
Thank you!
First, don't move program files just like that. Programs don't store data only here. Absence of this data might prevent some programs from running, especially licensed ones because they will think it's an attempt of running the executable directly on another computer. A better solution is to reinstall the programs, as it will put everything in the good place to make it is running OK.
Here's the command:
xcopy <Source> <Destination> /s /y
Replace <Source> and <Destination> with their appropriated values. Example:
xcopy C:\Windows.old\Users\David C:\Users\David /s /y
xcopy will ask if it is a file or folder destination. Answer that it is a folder by typing the appropriate letter.
Explanations:The /s command line switch means to copy the entire file and folder structure, while /y means to not ask when overriding files. If you want to look even more geeky, add /f.