Tag Info

Hot answers tagged

11

Your question sounds like you want the first 10 files from every subfolder? This ought to do it (not exhaustively tested!): echo off xcopy /Y %1 %2 /T /E dir %1 /b /s /A:D >tempfolderlist.txt for /f "tokens=1 delims=¬" %%a in (./tempfolderlist.txt) do ( dir "%%a" /b /A:-D >tempfilelist.txt setlocal enabledelayedexpansion set counter=0 ...


6

Robocopy has far more options and is built in on most recent Windows versions. robocopy source-dir destination-dir filespec /E /XC /XN /XO This will only copy across files that meet filespec (e.g. *.avhd in your example) from source dir (c:\Hyper-V\vhd in your example) to destdir (z:\backup\hyperv_vms). The switches tell it to skip older, newer and ...


3

Robocopy is your friend in this. It has a flag that'll do exactly what you want. robocopy c:\ f:\ /mir /r:1 /sec That'll do a mirror copy, retrying open files once before moving on, and will also copy security. The mirror copy will also remove files from F:\ that no longer exist on C:\, which is something xcopy can't do. Also, after the first sync it'll ...


2

For something that old, running on Windows 2003 (I assume) I'd probably go with robocopy or something similar. For Windows 2008 servers I use DFS between the servers (for the sites that need it like WordPress). For sites that where all files are pushed by a sysadmin we just push to each server manually so we keep pull one server out of the load balencer at ...


2

I would use rsync for this purpose. You can download a Windows-compatible binary or get it as part of Cygwin (I recommend the former approach unless you already have Cygwin installed). You can either push files to the remote site or pull from it. I prefer the pull method, but either will do. Using the pull method, the rsync daemon will run on the source ...


2

The /M parameter tells it to copy only files with the "Archive" attribute set, and resets that attribute at the same time. The "archive" bit is a part of the file system, like the "Read Only" bit or the "System file" bit. It was traditionally used for old-fashioned "naive" backup software so that it could tell whether or not a file had been changed since it ...


1

If you only want the first 10 files out of the whole structure, you could use this (heavily borrowed from Owen's answer!) @echo off mkdir %2 dir %1 /b /s /A:-D >tempfilelist.txt setlocal enabledelayedexpansion set counter=0 for /f "tokens=1 delims=¬" %%b in (./tempfilelist.txt) do ( IF !counter! LSS 10 call :docopy "%%b" %2 set /a ...


1

Assuming the source server is Windows, you could add a static route to the backup server via the second interface. example interface A 192.168.1.10, Interface B (for backups) 192.168.1.11. Backup server 192.168.1.50 from an elevated command prompt, type route print and take note of the Interface List at the top of the output. Identify the interface on ...


1

Have you added a /Y to allow overwriting the destination directory? I've had better luck with: xcopy E:\Images*.* Z:\Images*.* /D /E /Y The account under which you are running xcopy may not have permission to delete the folder/files on the remote server. Check permissions on the server.


1

Are you trying to "mirror" the E: drive, meaning if you add/delete a file in E: you want it added/deleted in Z:? If so, robocopy would be your best bet. The command would basically look like this: robocopy E:\Images Z:\Images /mir If you need to mirror the ACLs, you could add /copyall as well.


1

From the xcopy technet page: If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory. Since you're ...


1

One way I have gotten past this error is to use runas. If you have access to a command line, then use /runas:<domain>\<domainadmin> cmd.exe. You will get a second command line that runs with domain admin credentials. (Note: to perform on windows 7, you may have to elevate past the UAC.) Once you have your domain admin command line, continue on ...


1

Unlikely. It's pretty likely that the copied files are using the same physical hard drive clusters as the old files, and the data is just gone. On a journaling file system there might be a higher chance of recovering data. In general though this is a good reason to use backups and source control.


1

One school of thought would say that if the file is corrupt anyway, all that a backup of it would give you is the ability to restore some corruption, so using the /C switch on xcopy is a viable approach. You should be aware however that xcopy can occasionally misreport a corruption on what is a perfectly good file. One place I've definitely seen this ...


1

That web deployment tool is good! Disclosure: MSFT employee, clearly biased! The Web Deployment Tool can migrate sites and apps between servers, and has some really useful features for determining whether configuration has drifted between servers within a farm. Generally, you -verb:sync content into a package of some sort, then you can -verb:sync or ...


1

I suspect the difference lay in date resolution differences as reported by Samba and as stored in the file-system. It could be that Samba is reporting dates with the micro-seconds zeroed, where the file-system is storing microseconds, and xcopy/robocopy care about that. Without cracking open a sniffer I can't prove it, but it is a guess.


1

It seems that error 4 means: "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line." EDIT: Microsoft's page on XCOPY


1

Let's break it down. You want to copy the My Documents folder and all its contents to some location. Groovy. Folder Redirection (/Offline Files) via Group Policy isn't how you're going about it, though. Fair enough; it's not for everyone. But there are a ton of assumptions built into your script, and there's probably easier ways of doing it. Instead, you ...



Only top voted, non community-wiki answers of a minimum length are eligible