1.

Solve : How to combine forfiles and for loop script to run the file?

Answer»

Quote from: _unknown_ on November 03, 2014, 09:00:36 PM

There is a "system cannot find the path specified above". Here is how I set my path.

@echo off
set in_path=E:\input\
set out_path=E:\output

set temp_path=%out_path%\temp\
set processed_files_path=E:\processed files\
md "%processed_files_path%" 2>nul
cd /d "%in_path%"

You have changed this in more ways than only changing the paths and I have no confidence that you have not also introduced other changes...


The error message you mentioned is only cosmetic and you can stop it appearing by changing this in two places:
rd "%temp_path%"
to
rd "%temp_path%" 2>nul

I predict 5 pages TOTAL for this THREAD....Quote from: Squashman on November 05, 2014, 06:40:24 AM
Lets see the entire batch file that you are using. Please keep it as is. Do not obfuscate anything.

The following are the entire batch file I am using from the input folder:

A2001274033500.L1_LAC.A.hdf
A2001274033500.L2_LAC.A.hdf
A2001274051000.L1_LAC.A.hdf
A2001274051000.L2_LAC.A.hdf
A2001274051500.L1_LAC.A.hdf
A2001274051500.L2_LAC.A.hdf
A2001274065000.L1_LAC.A.hdf
A2001274065000.L2_LAC.A.hdf
A2001275041500.L1_LAC.A.hdf
A2001275041500.L2_LAC.A.hdf
A2001275042000.L1_LAC.A.hdf
A2001275042000.L2_LAC.A.hdf
A2001275055000.L1_LAC.A.hdf
A2001275055000.L2_LAC.A.hdf
A2001275055500.L1_LAC.A.hdf
A2001275055500.L2_LAC.A.hdf
A2001275060000.L1_LAC.A.hdf
A2001275060000.L2_LAC.A.hdf


While the bat file is running here are the files I've pasted/added to the input folder from the desktop folder.

A2001038044500.L2_LAC.A.hdf
A2001038045000.L2_LAC.A.hdf
A2001038063000.L2_LAC.A.hdf
A2001038062500.L2_LAC.A.hdfI asked for the BATCH file code you are using!! Not what input files you are using!!!Quote from: Squashman on November 05, 2014, 09:37:43 PM
I asked for the BATCH file code you are using!! Not what input files you are using!!!

Sorry

@echo off
set in_path=E:\input\
set out_path=E:\output\

set temp_path=%out_path%\temp\
set processed_files_path=E:\processed files\
md "%processed_files_path%" 2>nul
cd /d "%in_path%"

:loop
set now=%date% %time%
if exist "*.L2_LAC.*.hdf" (
rd "%temp_path%" 2>nul
if exist "%temp_path%\" echo An ERROR occurred as the "%temp_path%\" folder exists - may

have UNPROCESSED files within: & pause & goto :EOF
md "%temp_path%" 2>nul
echo moving files @ %now%
move "*.L2_LAC.*.hdf" "%temp_path%" >nul
cd /d "%temp_path%"
echo projecting files
FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs EPSG:4326 -te 113.205 1.120 157.105 2.005 HDF4_SDS:UNKNOWN:@file:37 %out_path%\@fname.tif"
move "*.L2_LAC.*.hdf" "%processed_files_path%" >nul
cd ..
rd "%temp_path%" 2>nul
if exist "%temp_path%\" echo An ERROR occurred as the "%temp_path%\" folder exists -

may have unprocessed files within: & pause & goto
)

timeout /t 30 /nobreak
goto :loopWould it kill you to use bulletin board CODE tags like everyone else has been using.

You have two lines of code that are wrapping. If they are like that in your batch file they would cause some syntax errors.Quote from: _unknown_ on November 03, 2014, 09:00:36 PM
There is a "system cannot find the path specified above".

Quote from: foxidrive on November 05, 2014, 08:52:47 AM
The error message you mentioned is only cosmetic

Now that I look again - the error you quoted (without the word "above" in Win 8.1) is caused by a different problem,
but it would have to be such an elementary error that I can't BELIEVE you keep getting it...

The input folder doesn't exist, and so there can't be any source files in there.
This assumes that the batch file you pasted above is correct...
Quote from: Squashman on November 06, 2014, 06:39:06 AM
Would it kill you to use bulletin board CODE tags like everyone else has been using.

You have two lines of code that are wrapping. If they are like that in your batch file they would cause some syntax errors.

Code: [Select]@echo off
set "in_path=E:\input\"
set "out_path=E:\output"

set "temp_path=%out_path%\temp\"
set "processed_files_path=E:\processed files\"
md "%processed_files_path%" 2>nul
cd /d "%in_path%"

:loop
set now=%date% %time%
if exist "*.L2_LAC.*.hdf" (
rd "%temp_path%" 2>nul
if exist "%temp_path%\" echo An ERROR occurred as the "%temp_path%\" folder exists - may have unprocessed files within: & pause & goto :EOF
md "%temp_path%" 2>nul
echo moving files @ %now%
move "*.L2_LAC.*.hdf" "%temp_path%" >nul
cd /d "%temp_path%"
echo projecting files
FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs EPSG:4326 -te 109.975 3.475 135.025 25.025 HDF4_SDS:UNKNOWN:@file:37 %out_path%\@fname.tif"
move "*.L2_LAC.*.hdf" "%processed_files_path%" >nul
cd ..
rd "%temp_path%" 2>nul
if exist "%temp_path%\" echo An ERROR occurred as the "%temp_path%\" folder exists - may have unprocessed files within: & pause & goto
)

timeout /t 30 /nobreak
goto :loop
Quote from: foxidrive on November 05, 2014, 08:52:47 AM
You have changed this in more ways than only changing the paths and I have no confidence that you have not also introduced other changes...


The error message you mentioned is only cosmetic and you can stop it appearing by changing this in two places:
rd "%temp_path%"
to
rd "%temp_path%" 2>nul

This solved the error "can't find the path specified above". But after all the files from the input folder was projected successfully and those files were moved to the processed files folder then I've pasted 4 new files in the input folder I don't know why it isn't even working. It just keeps on waiting for 30 seconds But in your case it's working Because in the middle of the script you do a change directory to the temp path but never do a change directory back to the input path because it is outside the loop label.Quote from: foxidrive on October 30, 2014, 05:07:53 AM
Code: [Select] cd ..
rd "%temp_path%"
if exist "%temp_path%\" echo An ERROR occurred as the "%temp_path%\" folder exists - may have unprocessed files within: & pause & goto
)

timeout /t 30 /nobreak
goto :loop

Figured it out already. The cd .. part is causing the problem. Just modified it by changing the directory pointing to the input_path.
Thank you squashman and to you foxidrive who do all the efforts in creating this script and for your patience. Quote from: Squashman on November 06, 2014, 08:06:17 PM
Because in the middle of the script you do a change directory to the temp path but never do a change directory back to the input path because it is outside the loop label.

Well spotted Squashman. My test created extra files after the timeout command but it created them in the current directory, and of course it worked fine.


Anyway, it's solved after a lengthy battle, NICE work. Quote from: _unknown_ on November 06, 2014, 09:01:21 PM
Figured it out already. The cd .. part is causing the problem. Just modified it by changing the directory pointing to the input_path.
Thank you squashman and to you foxidrive who do all the efforts in creating this script and for your patience.


Discussion

No Comment Found