Problem with a batch file

  Housten 23:17 16 Jan 2012

  robin_x 23:28 16 Jan 2012

Will that be the one where the batch file opens and closes too quickly to see what it says?

  Housten 14:50 17 Jan 2012


Well I don’t know what happened there then!! Saw it was on the forum, after I had posted it – you know the usual ‘2 Views 11 Seconds ago’ - and had stupidly thought that it would stay there!! However what I was asking was what I had done wrong when I had written what I had thought was a simple programme!! I used to write – admittedly in BASIC – simple programmes, and along the way I found out, and used, batch files. Recently I realised it would be a good idea to copy some important data to a USB pen drive on a regular basis – even if I felt it was necessary daily. It was getting a bit boring having to copy and paste all the time, and then I remembered about batch files. As some of you may know being a pensioner I am now a bit brain dead. Nevertheless I tried writing a batch file which I thought would be easy, although I now have Windows 7 Home Premium I thought with the ‘Command’ capability it wouldn’t/shouldn’t make any difference to the way of writing a batch file. I had found out that when you have a blank space in a folder description this then needs the whole of the original folder’s description to be included within quotation marks. Well I have tried with and without and many other combinations, and have got absolutely nowhere. I have called the file – simplistically I know – ‘Quickfast’ and have listed it below, which is my latest attempt, and I would be really grateful if some kind and patient person could either explain where I have gone wrong or do a re-write of it for me. I know I have only spent a few hours on this but I would really like to get this correct. Any and all help/information/advice will be very gratefully received.


XCOPY ‘C:\My Documents\Quicken Data*.* M:\ \Quicken Data XCOPY ‘C:\My Documents\Quicken Data\Backup*.* M:\ \Quicken Data\Backup

Thank you in advance for any contribution.

  Peter 15:27 17 Jan 2012


I'm not sure if any of my suggestion will help; it's been a long time since I wrote any Batch files in anger.

I think the quotes you need to use for long file names and paths should be double quotes, not single quotes, but I could be wrong. Also you need to close the quotes as well as opening them; your example appears just to open then.

You seem to have missed out the back slash before both. but I think that could just be the way this noticeboard interprets the use of asterisks (stars).

Also the final part "M:\ \Quicken Data\Backup" seems to be unnecessary.

I think the line below might be an improvement, but you will need to replace each Sun symbols (?) by a star (Shift 8).

XCOPY "C:\My Documents\Quicken Data\?.?" M:\ \Quicken Data XCOPY "C:\My Documents\Quicken Data\Backup\?.?"

I hope this help, but if not perhaps someone else with more knowledge will come to your aid.


  Eric10 20:03 17 Jan 2012

This assumes that M: is your USB Pen Drive.

xcopy "C:\My Documents\Quicken Data*.*" "M:\Quicken Data\Backup" /M /Y


the /M switch ensures that only files that have changed since last backed up are copied.

the /Y switch stops xcopy asking for confirmation to overwrite each destination file.

pause keeps the command prompt open so that you can see the results.

  Eric10 20:06 17 Jan 2012

I forgot to mention that if you put

@echo off

as the first line then it will prevent unnecessary output appearing on the screen.

  robin_x 20:47 17 Jan 2012

xcopy /? lists the syntax and switches.

Also works for any DOS command.

I find it convenient to have a Shortcut to cmd.exe on my Desktop set to Run As Administrator. I hate opening a command prompt, typing a long batch command and it failing because of wrong permissions.

(Properties/Shortcut Tab/Advanced)

  Housten 11:25 19 Jan 2012


Many thanks to you all. I apologise for not seeing all your answers yesterday but we went t0 Town to see the brilliant Leonardo exhibition. I will try all your suggestions. As a point of interest I have the Command prompt as am icon on my 'quick launch' - if that is the correct terminology - and have had through XP, Vista and now 7!

Many, many thanks everyone.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Dell XPS 13 9370 (2018) review

Best Keyboards for Designers & Artists

What to ask Siri on the HomePod

Meilleurs VPN (2018)