Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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\PRINTERI 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

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

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.

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.

![]() |
![]() |
![]() |

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