Let's say I have a batch file. The input directory is C:\web\site\batch\username\usernumber. The output directory depends on where do you want the output to be stored. My problem is, if I am the user how will I still process the data/files from my input directory if the input directory username and usernumber changes?(I'm not the only user, if the batch file will be copied by another user the input directory username and usernumber will also change ). I have run the batch here is my input directory, C:\web\site\batch\first_user\0000, when another user run the batch the input directory changed to, C:\web\site\batch\second_user\0001. Is there any way that I could process the data/files from the input directory even if the username and usernumber changes? Only the C:\web\site\batch will not change(fixed).
Note:
The reason for this is that we are downloading from a website and then every time any user will download, the data downloaded will be stored to a chosen directory C:\web\site\batch. The web\site\batch is the website name and your username and usernumber will be added in the end.
Thanks!
Process files even if the path name changes
Moderator: DosItHelp
Process files even if the path name changes
Last edited by therealme on 27 May 2015 20:12, edited 1 time in total.
Re: Process files even if the path name changes
I just edited my question but the one who posted a reply was deleted. ;(
Re: Process files even if the path name changes
You can process the folder two levels higher, but the seeing way you have coded the batch script
will let us know how to give you appropriate advice.
Without seeing the code this thread could become long and twisted, while we try to ascertain
what you have done that makes our suggestion fail.
will let us know how to give you appropriate advice.
Without seeing the code this thread could become long and twisted, while we try to ascertain
what you have done that makes our suggestion fail.
Re: Process files even if the path name changes
Code: Select all
@echo off
set "input_here=C:\web\site\batch\user1\0001\"
set "output_here=C:\web\site\output\"
set "proc_here=C:\web\site\proc"
md "%output_here%"
md "%proc_here%" 2>nul
cd /d "%input_here%"
for %%a in (.bmp) do (
set "fileName=%%a"
FORFILES /m %%a /C "cmd /c Copy @file %output_here%\@fname.bmp"
move %%a "%proc_here%" 2>nul
)
The user1\0001 from the input_here will change. Since the input_here directory for this batch process will have different user and number.
Re: Process files even if the path name changes
To do this, you'll need to prompt for the user name and number and then store them in a variable that you can use in your existing batch file. Considering how well your batch is already written, I think you can handle it. It's definitely not something I've done in a long time.
Re: Process files even if the path name changes
therealme wrote:Code: Select all
@echo off
set "input_here=C:\web\site\batch\user1\0001\"
The user1\0001 from the input_here will change. Since the input_here directory for this batch process will have different user and number.
Where will the batch file live?
echo "%userprofile%" will show you which user is operating the script and the home folder tree.
It's not clear where 0001 comes into the equation.