Solved Need Help for my batch

December 8, 2012 at 20:36:23
Specs: Windows 7 Premium SP1 64 bits

Hi everyone !

It's my first time on this forum, so I hope you will excuse me if I don't do things as they should be done....

I need to do a batch file that allow me to do this:

In a first directory (directory_1), I have some subdirectories and different doc files inside (but with some others files).
In a second directory (directory_2), I have some subdirectories and different pdf files.

Special doc files (in directory_1), called ERG_xxxx.doc, are generated by a software and must be converted (manually for the moment) in pdf files and saved in a directory (inside directory_2).

A friend, not available for the moment, write this code that allow me to find all the DOC file present in directory_1 and not already converted in directory_2.

But:

1) I want to convert only doc file when the name contain "ERG". Can we use two search string with FIND ?
2) When the batch find the not allready converted doc file, it give me only the name (and extension) of the file. Not the complete path with name and extension that is necessary to convert the file with pdfcreator.exe....

Can somebody help me please ?

Thanks..

A soooo Newbie,
Karl.

The code:

----------------
@echo off
setlocal enabledelayedexpansion

set DIRECTORY_1=E:\try\1
set DIRECTORY_2=E:\try\2

for /f "tokens=*" %%§ in ('dir %DIRECTORY_1% /b /s ^| find /i ".doc"') do call :VERIF "%%~nx§"

pause
exit

:VERIF
dir %DIRECTORY_2% /b /s | find "%~n1" >nul
if not %errorlevel%==0 pdfcreator.exe /NoStart /PF"%~nx1"
goto :EOF


See More: Need Help for my batch

Report •


#1
December 9, 2012 at 00:44:47

::You can do your own directory fixups.
::but here's the gist of it.

:: =====  script starts here  ===============
:: 
:: karl.bat  2012-12-09 15:17:09.03
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=* delims= " %%a in ('dir/b/s d:\files\*.doc ^| find /i "erg"') do (
set D=%%~Na
if not exist !D!.pdf echo convert %%a
)
::======  script ends here  =================

=====================
M2 Golden-Triangle


Report •

#2
December 9, 2012 at 14:16:13

Hi Mechanix2Go, Hi everyone.

Many thanks for your answer.
This code resolve my problem allowing me find files with 2 conditions ("name contains "ERG" and DOC files).

But I still cannot have the path AND name of these ERG DOC files to send them to pdfcreator...


:: ===== script starts here ===============

@echo off
setlocal enabledelayedexpansion

set DIRECTORY_1=E:\try\1\*.doc
set DIRECTORY_2=E:\try\2

for /f "tokens=*" %%§ in ('dir /b /s %DIRECTORY_1% ^| find /i "ERG"') do call :VERIF "%%~nx§"

pause
exit

:VERIF
dir %DIRECTORY_2% /b /s | find "%~n1" >nul
if not %errorlevel%==0 pdfcreator.exe /NoStart /PF"%~nx1"

goto :EOF


::====== script ends here =================

Please help !
Many Thanks,
Karl.


Report •

#3
December 11, 2012 at 10:38:17
✔ Best Answer

The following script as response to your private message.

@echo off & setlocal

set DIRECTORY_1=E:\try\1
set DIRECTORY_2=E:\try\2

for /F "tokens=*" %%j in ('dir /B /S "%DIRECTORY_1%\*.doc" ^| find /I "ERG"') do (
  dir "%DIRECTORY_2%" /B /S | find "%%~nj" >nul || pdfcreator /NoStart /PF"%%~j"
)
pause


Report •

Related Solutions

#4
December 16, 2012 at 17:50:53

Hello IVO, hello everyone.

Thanks for answering to me so quickly.
This script do exactly what I need.
Thank you SO MUCH for your help...

Karl.


Report •


Ask Question