Computing.Net > Forums > Disk Operating System > Batch File Copy Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Copy Help

Reply to Message Icon

Name: CraigWalker
Date: March 13, 2008 at 09:23:46 Pacific
OS: 5.1.2600 Service Pack 2 B
CPU/Ram: x86 Family 15 Model 2 Ste
Product: Hewlett-Packard/HP d330 u
Comment:

I know this isn't exactly a DOS question but this seemed like the best place to post.

I currently send files to my printer with a batch file.
copy /b %1 \\PATH_TO_PRINNER\PRINTER

I either drag a file onto this batch or use it in the "SendTo".

This works fine, however I want to modify this to do one of two things.

After the copy is complete I want to rename or move the file %1 to show that it has been printed.

If I move the file I want to create a dir named PRINTED in the DIR where %1 sits and then move it in there.

If I rename the file I want to append _Printed after the filename but before the extension.

I have thought about deleting the file %1 after printing, therefore I know it's been printed because it is no longer available but in some instances I may need to reprint the file, that is why I need to rename or move.

Is this possible? If it is I would appreciate help doing this.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: March 13, 2008 at 10:14:47 Pacific
Reply:

copy /b %1 \\PATH_TO_PRINNER\PRINTER
if not exist %~dp1\PRINTED MD %~dp1\PRINTED
move %1 %~dp1\PRINTED


0

Response Number 2
Name: CraigWalker
Date: March 14, 2008 at 01:36:02 Pacific
Reply:

Thanks for your input IVO.

This works on directorys without any spaces in the name. I.E. J:\LaserPrint\TEST\ but when you introduce spaces in the path it gives this error.

C:\>copy /b "J:\LaserPrint\TEST\TEST WITH SPACE\TEST.001" \\Offfileserver\HP8150DNO
1 file(s) copied.

C:\>if not exist J:\LaserPrint\TEST\TEST WITH SPACE\\PRINTED MD J:\LaserPrint\TEST\TEST WITH SPACE\\PRINTED
'WITH' is not recognized as an internal or external command, operable program or batch file.

C:\>move "J:\LaserPrint\TEST\TEST WITH SPACE\TEST.001" J:\LaserPrint\TEST\TEST WITH SPACE\\PRINTED
The syntax of the command is incorrect.

C:\>pause
Press any key to continue . . .


I have just corrected your code by placing quote marks around the path.

copy /b %1 \\Offfileserver\HP8150DNO
if not exist "%~dp1\PRINTED" MD "%~dp1\PRINTED"
move %1 "%~dp1\PRINTED"

Thanks for your help IVO.


0

Response Number 3
Name: CraigWalker
Date: March 14, 2008 at 07:46:40 Pacific
Reply:

With IVO's highlighting %~dp1 I was able to find more info about that command.

I found a webpage that explained quite a few of these commands and I was able to find how to split the filename variable.
The webpage is http://weblogs.asp.net/jgalloway/ar...

So my final code is this;
copy /b %1 \\Offfileserver\HP8150DNO
set FileNameOnly=%~n1
set FileExtension=%~x1
set FileNameWithExt=%~nx1
if not exist "%~dp1\LASERED SEGMENT DUMP" MD "%~dp1\LASERED SEGMENT DUMP"
move %1 "%~dp1\LASERED SEGMENT DUMP"
cd "%~dp1\LASERED SEGMENT DUMP"
ren %FileNameWithExt% "%FileNameOnly%_Lasered%FileExtension%"

This copies the file to the printer in binary. (Prints)
Then creates a directory called LASERED SEGMENT DUMP if it doesn't exist.
Then moves the file to the directory and finally renames the file appending _Lasered after the filename but before the extension.

Everything I was looking for.

Thank you IVO.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch File Copy Help

Batch file copy HELP www.computing.net/answers/dos/batch-file-copy-help/11356.html

Simple copy batch file, please help www.computing.net/answers/dos/simple-copy-batch-file-please-help/11154.html

Batch file..........Need help Please www.computing.net/answers/dos/batch-fileneed-help-please/11162.html