PPRuNe Forums

PPRuNe Forums (https://www.pprune.org/)
-   Computer/Internet Issues & Troubleshooting (https://www.pprune.org/computer-internet-issues-troubleshooting-46/)
-   -   Windows7 Batch Files - stumped! (https://www.pprune.org/computer-internet-issues-troubleshooting/538178-windows7-batch-files-stumped.html)

BOAC 18th Apr 2014 12:30

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].)

Bushfiva 18th Apr 2014 12:42

Code:

Dir "C:\Documents\Outlook Files"

Or, if you're lazy,


Code:

Dir "C:\Documents\Outlook Files

BOAC 18th Apr 2014 13:34

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.

Bushfiva 18th Apr 2014 13:54

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

BOAC 18th Apr 2014 14:18

Aha! - so simple! Thanks. Daily mail backups now scheduled.

mixture 18th Apr 2014 14:22

Batch files are so 1999.... you should be using PowerShell, its what all the cool kids use. :cool:


copy C:\Documents\Outlook Files
No, no no and NO ! :cool:

"copy" is by no way as robust as robocopy.

The latter I would trust (with appropriate command line flags), the former I would not.

BOAC 18th Apr 2014 15:11

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.

Bushfiva 18th Apr 2014 15:37

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.

mixture 18th Apr 2014 16:05

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..... :p

Mac the Knife 20th Apr 2014 11:15

What's wrong with xcopy? Much richer than plain ol' copy and more efficient!

Mac

:hmm:

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

:ooh:

mixture 20th Apr 2014 12:21


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..... :cool:

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" :)

Keef 21st Apr 2014 00:56

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

cattletruck 21st Apr 2014 04:51

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.

Mac the Knife 21st Apr 2014 11:49

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

:ooh:

Saab Dastard 21st Apr 2014 12:14

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

Keef 21st Apr 2014 23:11

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.

Mac the Knife 22nd Apr 2014 07:21

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.


All times are GMT. The time now is 09:10.


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