Windows7 Batch Files - stumped!
Per Ardua ad Astraeus
Thread Starter
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes
on
0 Posts
Windows7 Batch Files - stumped!
In the process of updating existing scheduled tasks from old 32bit W7 to 64bit W7, I am stuck with batch files (after all these years!)
UAC on or off:
Dir C:\ produces the directory
Dir C:\Documents likewise
Dir C:\Documents\Outlook Files produces 'file not found' ?? Folder and files are there.
Why? Permissions are, as far as I know, set OK, as is ownership.
(The aim is to Robocopy C:\Documents\Outlook Files\Outlook.pst to a backup location [with Outlook dead, of course].)
UAC on or off:
Dir C:\ produces the directory
Dir C:\Documents likewise
Dir C:\Documents\Outlook Files produces 'file not found' ?? Folder and files are there.
Why? Permissions are, as far as I know, set OK, as is ownership.
(The aim is to Robocopy C:\Documents\Outlook Files\Outlook.pst to a backup location [with Outlook dead, of course].)
Per Ardua ad Astraeus
Thread Starter
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes
on
0 Posts
That seems to have fixed it - thanks BF - oddly, though, Dir C:\ produces the directory without the "" and Dir C:\Documents did not need the "" either.
Hippopotomonstrosesquipidelian title
Join Date: Oct 2006
Location: is everything
Posts: 1,826
Likes: 0
Received 0 Likes
on
0 Posts
Directories with spaces in them need quoting otherwise the unexpected can happen. Consider the syntax using "copy" instead of "dir" for your examples, where both \outlook and \outlook files exist:
Code:
copy C:\Documents\Outlook Files
Join Date: Aug 2002
Location: Earth
Posts: 3,663
Likes: 0
Received 0 Likes
on
0 Posts
Batch files are so 1999.... you should be using PowerShell, its what all the cool kids use.
No, no no and NO !
"copy" is by no way as robust as robocopy.
The latter I would trust (with appropriate command line flags), the former I would not.
copy CDocuments\Outlook Files
"copy" is by no way as robust as robocopy.
The latter I would trust (with appropriate command line flags), the former I would not.
Per Ardua ad Astraeus
Thread Starter
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes
on
0 Posts
Thanks for shouting - Robocopy was my first choice but threw errors. As a 'hot daddy' I'll stick where I am at the mo.
PS You can disable smilies.
PS You can disable smilies.
Hippopotomonstrosesquipidelian title
Join Date: Oct 2006
Location: is everything
Posts: 1,826
Likes: 0
Received 0 Likes
on
0 Posts
FFS Mixture, I'm illustrating a point, not advocating a way moving data around. I'll say FFS again, because some threads simply don't need your hobnails all over them. FOM.
Join Date: Aug 2002
Location: Earth
Posts: 3,663
Likes: 0
Received 0 Likes
on
0 Posts
Bushfiva,
You could have easily used the command robocopy in your example and there would have been no issue.
Instead you opted to use "copy" .... which was a bad example in the context of someone trying to do backups of his outlook folder.
So FFS yourself.....
You could have easily used the command robocopy in your example and there would have been no issue.
Instead you opted to use "copy" .... which was a bad example in the context of someone trying to do backups of his outlook folder.
So FFS yourself.....
Plastic PPRuNer
What's wrong with xcopy? Much richer than plain ol' copy and more efficient!
Mac
But why not use dedicated multithreaded copy tools?
Richcopy - Free Utility: RichCopy, an Advanced Alternative to RoboCopy is better than Robocopy and xxcopy - XXCOPY, A Versatile File Management Utility --- Boldly Extended Xcopy is is better suited to some tasks. And as mix says, you can always cobble together a Powershell script.
But ahhh batch files - gotta love 'em! Write 'em right, with lots of sanity checks and errortrapping and they'll always get you home...
Mac
Mac
But why not use dedicated multithreaded copy tools?
Richcopy - Free Utility: RichCopy, an Advanced Alternative to RoboCopy is better than Robocopy and xxcopy - XXCOPY, A Versatile File Management Utility --- Boldly Extended Xcopy is is better suited to some tasks. And as mix says, you can always cobble together a Powershell script.
But ahhh batch files - gotta love 'em! Write 'em right, with lots of sanity checks and errortrapping and they'll always get you home...
Mac
Join Date: Aug 2002
Location: Earth
Posts: 3,663
Likes: 0
Received 0 Likes
on
0 Posts
What's wrong with xcopy? Much richer than plain ol' copy and more efficient!
I seem to recall hearing that when you type "xcopy /?" these days on Windows Server, you get a message saying "NOTE: Xcopy is now deprecated, please use Robocopy." .... nuff' said.....
Think I'll start saying the same thing when people type "Windows XP" on PPRuNe .... "XP is now deprecated, please use 7,8,Mac or Linux"
Official PPRuNe Chaplain
Join Date: Apr 2001
Location: Witnesham, Suffolk
Age: 80
Posts: 3,498
Likes: 0
Received 0 Likes
on
0 Posts
I used a set of batch files using xcopy to do backups of my "stuff" the way I like it. It all worked OK (had done for many years).
A couple of months ago, that stopped working, with no indication of why. So I rewrote the batch files to use robocopy. After a couple of "fixes", I got it working again as it did before.
...until I came to deleting old backups made with robocopy. The standard "delete" command wouldn't work on the backup folders - most of the stuff would go, then error messages appeared and the delete stopped, leaving a load of bits lying around. I've found a workaround now, but it's far more faff than ever xcopy was.
This is the robocopy command - can anyone see what in here locks some files where the xcopy equivalent didn't?
A couple of months ago, that stopped working, with no indication of why. So I rewrote the batch files to use robocopy. After a couple of "fixes", I got it working again as it did before.
...until I came to deleting old backups made with robocopy. The standard "delete" command wouldn't work on the backup folders - most of the stuff would go, then error messages appeared and the delete stopped, leaving a load of bits lying around. I've found a workaround now, but it's far more faff than ever xcopy was.
This is the robocopy command - can anyone see what in here locks some files where the xcopy equivalent didn't?
Code:
robocopy C:\Users\ R:\BU%date:~6,4%%date:~3,2%%date:~0,2%\C\Users\ *.* /s /r:0 /copyall /xj /A-:SH
Plastic PPRuNer
As I said, RichCopy is an advanced alternative to RoboCopy
"...though Robocopy GUI certainly improves on that basic functionality, it still has some limitations in terms of granular control and usability. What you need is RichCopy.
RichCopy is a free utility that comes...from Ken Tamaru of Microsoft. The tool was first developed in 2001 and has been updated regularly to keep pace with evolving needs. Trust me when I tell you, this is the answer to all your file copying needs. What you'll find most striking the first time you take RichCopy out for a spin is that it's a multithreaded copying tool. That means that rather than copying one file at a time in serial order, RichCopy can open multiple threads simultaneously, allowing many files to be copied in parallel and cutting the total time required to complete the operation several times over. You can also pause and resume file copy operations, so if you lose network connectivity at any point, you can just pick up where you left off. Of course, these are really just the simplest features of RichCopy."
And you can use it from the console.
Mac
"...though Robocopy GUI certainly improves on that basic functionality, it still has some limitations in terms of granular control and usability. What you need is RichCopy.
RichCopy is a free utility that comes...from Ken Tamaru of Microsoft. The tool was first developed in 2001 and has been updated regularly to keep pace with evolving needs. Trust me when I tell you, this is the answer to all your file copying needs. What you'll find most striking the first time you take RichCopy out for a spin is that it's a multithreaded copying tool. That means that rather than copying one file at a time in serial order, RichCopy can open multiple threads simultaneously, allowing many files to be copied in parallel and cutting the total time required to complete the operation several times over. You can also pause and resume file copy operations, so if you lose network connectivity at any point, you can just pick up where you left off. Of course, these are really just the simplest features of RichCopy."
And you can use it from the console.
Mac
Spoon PPRuNerist & Mad Inistrator
Keef, what were the error messages?
Anything to do with “file name too long”? If so, I would hazard a guess that the /XJ switch was a late addition to your command line!
SD
Anything to do with “file name too long”? If so, I would hazard a guess that the /XJ switch was a late addition to your command line!
SD
Official PPRuNe Chaplain
Join Date: Apr 2001
Location: Witnesham, Suffolk
Age: 80
Posts: 3,498
Likes: 0
Received 0 Likes
on
0 Posts
No, the /XJ is to exclude junction points. I don't want iTunes and a few others wearing out my SSD by constantly churning it, and since they insist on putting all their stuff down in the bowels of "Users", I've got sneakies in there to point them at their own spaces - mostly I: \Itunesjunk and the like.
Without the /XJ, the backup of C: \Users would copy all the garbage from I: \Itunesjunk, which gets backed up with Drive I anyway.
The error messages are mostly to do with me not being the owner of some of the files in the backup (for example System Volume Information) and therefore not allowed to delete them. I have to "take ownership" of them before I can delete.
xcopy didn't do that. I could click on a backup, shift-delete, and it would vanish. But then xcopy took to aborting part way through backing up a drive, and would move on to the next one: I couldn't find what was causing that (although I could identify the guilty folders). robocopy fixed that.
I've not had any errors at all copying - that part seems to work fine. Filenames seem not to cause problems, and even the umpty-level deep folders behave. I've got plenty that are 8 levels down - such as
It's empty, of course.
Without the /XJ, the backup of C: \Users would copy all the garbage from I: \Itunesjunk, which gets backed up with Drive I anyway.
The error messages are mostly to do with me not being the owner of some of the files in the backup (for example System Volume Information) and therefore not allowed to delete them. I have to "take ownership" of them before I can delete.
xcopy didn't do that. I could click on a backup, shift-delete, and it would vanish. But then xcopy took to aborting part way through backing up a drive, and would move on to the next one: I couldn't find what was causing that (although I could identify the guilty folders). robocopy fixed that.
I've not had any errors at all copying - that part seems to work fine. Filenames seem not to cause problems, and even the umpty-level deep folders behave. I've got plenty that are 8 levels down - such as
Code:
C:\Users\Keith\AppData\Roaming\Microsoft\SystemCertificates\Request\Certificates
Plastic PPRuNer
XXCopy compared to RoboCopy
Feature Comparison: XXCOPY vs ROBOCOPY
Mac
PS: I've been using TechSoftPl's "MirrorFolder" - MirrorFolder: A real-time folder synchronization and backup software - for years to keep folders in sync. You have to pay $39 for it and I could always have used a FOSS solution, but it's work faultlessly for me for years and I can't be bothered to change.
Gotta say that Richcopy hasta be the dogs bollocks for a Win environment.
Feature Comparison: XXCOPY vs ROBOCOPY
Mac
PS: I've been using TechSoftPl's "MirrorFolder" - MirrorFolder: A real-time folder synchronization and backup software - for years to keep folders in sync. You have to pay $39 for it and I could always have used a FOSS solution, but it's work faultlessly for me for years and I can't be bothered to change.
Gotta say that Richcopy hasta be the dogs bollocks for a Win environment.
Last edited by Mac the Knife; 22nd Apr 2014 at 07:33.