Go Back  PPRuNe Forums > Misc. Forums > Computer/Internet Issues & Troubleshooting
Reload this Page >

Windows7 Batch Files - stumped!

Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

Windows7 Batch Files - stumped!

Thread Tools
 
Search this Thread
 
Old 18th Apr 2014, 12:30
  #1 (permalink)  
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].)
BOAC is offline  
Old 18th Apr 2014, 12:42
  #2 (permalink)  
Hippopotomonstrosesquipidelian title
 
Join Date: Oct 2006
Location: is everything
Posts: 1,826
Likes: 0
Received 0 Likes on 0 Posts
Code:
Dir "C:\Documents\Outlook Files"

Or, if you're lazy,


Code:
Dir "C:\Documents\Outlook Files
Bushfiva is offline  
Old 18th Apr 2014, 13:34
  #3 (permalink)  
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.
BOAC is offline  
Old 18th Apr 2014, 13:54
  #4 (permalink)  
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
Bushfiva is offline  
Old 18th Apr 2014, 14:18
  #5 (permalink)  
Per Ardua ad Astraeus
Thread Starter
 
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes on 0 Posts
Aha! - so simple! Thanks. Daily mail backups now scheduled.
BOAC is offline  
Old 18th Apr 2014, 14:22
  #6 (permalink)  
 
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.

copy CDocuments\Outlook Files
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.
mixture is offline  
Old 18th Apr 2014, 15:11
  #7 (permalink)  
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.
BOAC is offline  
Old 18th Apr 2014, 15:37
  #8 (permalink)  
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.
Bushfiva is offline  
Old 18th Apr 2014, 16:05
  #9 (permalink)  
 
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.....
mixture is offline  
Old 20th Apr 2014, 11:15
  #10 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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 the Knife is offline  
Old 20th Apr 2014, 12:21
  #11 (permalink)  
 
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!
Robocopy still trumps it though.

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"
mixture is offline  
Old 21st Apr 2014, 00:56
  #12 (permalink)  

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?

Code:
robocopy C:\Users\ R:\BU%date:~6,4%%date:~3,2%%date:~0,2%\C\Users\ *.*  /s /r:0 /copyall /xj /A-:SH
Keef is offline  
Old 21st Apr 2014, 04:51
  #13 (permalink)  
 
Join Date: Apr 1998
Location: Mesopotamos
Posts: 5
Likes: 0
Received 0 Likes on 0 Posts
Hmmm, what's all this fluffing about with batch files and powershell, the second best thing you can do to a Windoze machine is install Cygwin.
cattletruck is offline  
Old 21st Apr 2014, 11:49
  #14 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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

Mac the Knife is offline  
Old 21st Apr 2014, 12:14
  #15 (permalink)  
Spoon PPRuNerist & Mad Inistrator
 
Join Date: Sep 2003
Location: Twickenham, home of rugby
Posts: 7,417
Received 281 Likes on 179 Posts
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
Saab Dastard is offline  
Old 21st Apr 2014, 23:11
  #16 (permalink)  

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
Code:
C:\Users\Keith\AppData\Roaming\Microsoft\SystemCertificates\Request\Certificates
It's empty, of course.
Keef is offline  
Old 22nd Apr 2014, 07:21
  #17 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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.

Last edited by Mac the Knife; 22nd Apr 2014 at 07:33.
Mac the Knife is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.