Process files even if the path name changes

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
therealme
Posts: 3
Joined: 26 May 2015 19:27

Process files even if the path name changes

#1 Post by therealme » 26 May 2015 20:29

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!
Last edited by therealme on 27 May 2015 20:12, edited 1 time in total.

therealme
Posts: 3
Joined: 26 May 2015 19:27

Re: Process files even if the path name changes

#2 Post by therealme » 28 May 2015 00:02

I just edited my question but the one who posted a reply was deleted. ;(

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Process files even if the path name changes

#3 Post by foxidrive » 28 May 2015 02:09

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.

therealme
Posts: 3
Joined: 26 May 2015 19:27

Re: Process files even if the path name changes

#4 Post by therealme » 28 May 2015 03:13

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.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Process files even if the path name changes

#5 Post by Samir » 28 May 2015 15:59

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. 8) It's definitely not something I've done in a long time.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Process files even if the path name changes

#6 Post by foxidrive » 29 May 2015 11:21

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.

Post Reply