We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message
Contact Forum Editor

Send an email to our Forum Editor:


PLEASE NOTE: Your name is used only to let the Forum Editor know who sent the message. Both your name and email address will not be used for any other purpose.

Tech Helproom


It's free to register, to post a question or to start / join a discussion


 

Another batch file problem.


Housten

Likes # 0

Good Afternoon [ !!! ],

I asked about what I thought was something easy, but after googling various things I am, now, more confused than ever! So I have revised what I want to do, and have realized – or think I have – that the simplest way would be to enter a number, right at the start of the file. And I must emphasize that – it will always be a number. This number will then be used to create a new sub-directory/sub-folder, which will then be written to. So what I want is something like:

Echo “What is number you wish to use”: Input %number% MD “G:\Mine\Backup\%number% [ or should this be %%number%%? ] ECHO OFF Xcopy “C:\bank data” “G:\Mine\Backup\%number%\bank data” and then I would use various parameters like ‘/s /e /c /h /y /v’ which I think will cover [ or more probably, more than cover ] all the options I will ever need, but I am going for the fullest amount so that once done, everything is covered and all bases are as well. As well as doing this folder and get it running properly, I will [ later ] be able to add other folders, and be able to save them where and when I want.

It is just getting the start correct that is proving really annoying, so if someone can tell me what to write I would be a very grateful pensioner.

Many thanks in anticipation.

Like this post
Eric10

Likes # 0

lotvic

Those are very interesting links you've provided. I knew about Powershell but hadn't really looked into it but it looks like it is the way to go.

Thanks

Eric

Like this post
Housten

Likes # 0

Good afternoon, Again!!

May be it's my age, may be it's not, but having got some of this batch file working at last, THE most important point doesn't. Again I am throwing myself open to comments of 'What an idiot!!' Below I list the [ small ] part of the file I am testing at the moment. It makes the folder I want, and then copies the Lacie folders and sub-folders! BUT NOT any of the files!! I can not see where I am going wrong, can someone please help?

@ECHO OFF echo %date% SET foldermonth=%date:~6,4%-%date:~3,2% echo %foldermonth% set folder=W:\RONBackup\C\%foldermonth% echo W:\RONBackup\C\%foldermonth% REM if not exist W:\RONBackup\C\%foldermonth% md %folder% echo starting Copy XCOPY /M /D /S /E /V /C /Q /G /H /J "C:\LaCie*.*" "%folder%" ECHO Elvis HAAS left the building!!!

After all I do say to copy 'C:\LaCie*.*'. I mean 13 folders and sub-folders are created/copied some of which ARE empty, but there over 80 files in total. And NOT ONE is copied!! Has anyone any idea, please??

Many thanks in anticipation

Like this post
Housten

Likes # 0

Whoops!! What happened?? Not a clue, but here is batch file as used:-

@ECHO OFF echo %date% SET foldermonth=%date:~6,4%-%date:~3,2% echo %foldermonth% set folder=W:\RONBackup\C\%foldermonth% echo W:\RONBackup\C\%foldermonth% if not exist W:\RONBackup\C\%foldermonth% md %folder% echo starting Copy XCOPY /M /D /S /E /V /C /Q /G /H /J "C:\LaCie*.*" "%folder%" ECHO Elvis HAAS left the building!!!

Sorry about that, I should have noticed!!

Like this post
Housten

Likes # 0

OK, OK I do not know what is happening!! I have tried - AGAIN - to show what the file looks like, and at the moment, it looks correct. But it did for the last one, so I can only assume that the forum is changing things around!! Her's hoping this time I have got it right!!!

@ECHO OFF echo %date% SET foldermonth=%date:~6,4%-%date:~3,2% echo %foldermonth% set folder=W:\RONBackup\C\%foldermonth% echo W:\RONBackup\C\%foldermonth% if not exist W:\RONBackup\C\%foldermonth% md %folder% echo starting Copy XCOPY /M /D /S /E /V /C /Q /G /H /J "C:\LaCie*.*" "%folder%" ECHO Elvis HAAS left the building!!

Many thanks for taking the trouble if you read this far!!

Like this post
Housten

Likes # 0

Well it has done it again. What I am going to do now is to write ' REM NEW LINE' at the END of every one of my lines. At least you will be able to see where each line starts/finishes!! [ Well known hope or phrase!!!! ]

@ECHO OFF REM NEW LINE - echo %date% REM NEW LINE - SET foldermonth=%date:~6,4%-%date:~3,2% REM NEW LINE - echo %foldermonth% REM NEW LINE - set folder=W:\RONBackup\C\%foldermonth% REM NEW LINE - echo W:\RONBackup\C\%foldermonth% REM NEW LINE - if not exist W:\RONBackup\C\%foldermonth% md %folder% REM NEW LINE - echo starting Copy REM NEW LINE - XCOPY /M /D /S /E /V /C /Q /G /H /J "C:\LaCie*.*" "%folder%" REM NEW LINE - ECHO Elvis HAAS left the building!!! REM NEW LINE -

Right then!! For the third time of asking!! If this doesn't work, I give up!!

Like this post
Housten

Likes # 0

OK, it now looks like I have a serious problem, with Windows. I have Windows 7 64Bit Home Premium and I tried something really simple :-

XCOPY "C:\LaCie*.*" "W:\RonBackup\C\2012-07"

to see what/which files would be copied. None were!!! So I am now totally flummoxed. Any ideas as to how I can over come this would be especially welcome!!

Many, many thanks in anticipation of any help!!

Like this post
Eric10

Likes # 0

Okay, it's the forum that is messing with the code as you type it in. Since you don't have any spaces in the names now you don't need to use the double quotes. The simplified line should be:

XCOPY C:\LaCie\*.*  W:\RonBackup\C\2012-07

Note that to get the backslash imediately after LaCie to display in the forum I have had to resort to entering html code for the backslash and the asterisks while keeping a check on the preview box just below the typing-in area every step of the way.

If that's exactly what you already have then I don't know what's happening. You have created the folders to match the new names haven't you?

Like this post
lotvic

Likes # 0

Put ECHO ON so you see it doing it in Cmd window and Add a last line

pause

so it stops on screen and you can study where it doesn't do what you want.

If you want text to start a new line on pca post you have to

leave

a blank line

inbetween

Like this post
Housten

Likes # 0

Eric10 and lotvic,

First of all many thanks to both of you.

Obviously I am fated never to get this working. First of all, Eric10, I just pasted your xcopy into a 'Command Prompt' window. I pressed enter and, almost instantaneously, '0 files copied' appeared! Then I entered 'echo on' as you suugested,lotvic, and.......'0 files copied' appeared!!

What is going on - or rather NOT going on, wiyhin my stupid computer I do not know. It is looking like I will have to give up on this, which will really annoy me as I have written many '.bat' previously - granted many years ago - but I have never had such a problem!!

It may well be that I am doing something wrong, but then again I do not think so. Perhaps being a brain dead pensioner I should be considered an arrogant brain dead pensioner!! I don't know, but I do know that I will give up on this shortly if it doesn't start working.

So many, many thanks to you both for all your help. I would love to be able to say that your suggestions have worked, but, I am afraid, they haven't and - as I say above - I do not believe any of it is down to either of you. It is either something I have - or not have - done OR - which I consider the more likely, my computer. I know for instance that there are some problems with it, but I have treid to repair these using th original installation disk and it stated that there were no problems. So I guess I am just going to have to live with this stupidity.

Many thanks for all your help and assisstance.

Like this post
Eric10

Likes # 0

I've just created a LaCie folder in the root of my C: drive and put 4 test files into it.

I then copied the XCOPY line from my post of Yesterday at 7:51PM. The only change I made is to make the destination drive D: rather than W: because I don't have a W: drive. I pressed Enter and was asked: "Does D:\RonBackup\C\2012-07 specifys a file name or directory name on the target (F = file, D = directory)" to which I answered D. This was because I hadn't already created the target folders. The output in the DOS box showed 4 files copied and listed them.

Upon inspecting D:\RonBackup\C\2012-07 using Explorer all 4 files were there.

I then re-ran the line once more (again changing W: to D:) and this time it asked permission to overwrite each file which I allowed.

So I'm afraid that I don't know what you are doing wrong. If you have copied and pasted some of the earlier listings then you could have had some errors due to the way the forum has been handling them but the one mentioned above tests out ok.

Like this post

Reply to this topic

This thread has been locked.



IDG UK Sites

Where to buy iPhone 6 and iPhone 6 Plus in the UK: Launch day price, deals and contracts

IDG UK Sites

Is Apple losing confidence in itself?

IDG UK Sites

Professional photo and video techniques for perfect colours

IDG UK Sites

How (and where) to buy an iPhone 6 or iPhone 6 Plus in the UK. Plus: What to do if you pre-ordered...