Batch moving using text file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

Re: Batch moving using text file

#16 Post by foxidrive » 28 Jun 2012 06:44

There are two versions of the list.txt file format there, and two batch files.

Which one are you using?

alperefe
Posts: 9
Joined: 20 Jun 2012 21:22

Re: Batch moving using text file

#17 Post by alperefe » 29 Jun 2012 04:01

I am using the first one. it is exact same order and folder design. I ve checked it many times so its not the issue I think. may be someone can post a whole working batch. of if anyone can manage to make something similar to this it would be great. all I want a batch that will create a bunch of folders from a list if they dont exist and copy stuff/files if the files are newer than the old ones.

thanx in advance.

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

Re: Batch moving using text file

#18 Post by foxidrive » 29 Jun 2012 06:44

alperefe wrote:all I want a batch that will create a bunch of folders from a list if they dont exist and copy stuff/files if the files are newer than the old ones.


So from the first post and using the first list, you have a list like this:

Code: Select all

001S.pdf|D:\Auditing Reports\A\B\S-88.pdf
002S.pdf|D:\Auditing Reports\C\D\S-87.pdf


and you want to copy 001S.pdf from the current folder to "D:\Auditing Reports\A\B\" and call it S-88.pdf
Judging from what you've said above that is not what you want

How about you explain where and how the folders/files are listed and which files you want copied, if they are newer then existing files.

alperefe
Posts: 9
Joined: 20 Jun 2012 21:22

Re: Batch moving using text file

#19 Post by alperefe » 29 Jun 2012 20:36

batch will create one folder named "build" and under it, will be folders like these:

Global
Image
Mount\Boot
Mount\MountBasic
Mount\MountPremium
Mount\MountPro
Mount\MountStarter
Mount\MountUltimate

batch will create these folders if they are non-existant and after creation it will copy itself into "build" folder so final structure will be something like this:
also the folder list can be inside the batch itself or outside as a list.txt something it doesnt matter.

Build\global
Build\Image
Build\Mount\boot
Build\batch_itself.cmd etc...

and in the "Global" folder will be files like;

attended.xml
setup.cmd

I will create those files manually so its no problem.

what I want is to check those files from global folder and if they are newer i want them to be copied inside "Image" folder and rename the older one inside image folder something else everytime the batch runs as it will check the folders everytime it runs. the name of the files can be something like this: setup.old

I was trying to implement the code in the first post into my project but it didnt work at all.

so thanx for your help in advance.

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

Re: Batch moving using text file

#20 Post by foxidrive » 29 Jun 2012 20:59

This should create the folders if they are missing.

Code: Select all

@echo off
for %%a in (
build\Global
build\Image
build\Mount\Boot
build\Mount\MountBasic
build\Mount\MountPremium
build\Mount\MountPro
build\Mount\MountStarter
build\Mount\MountUltimate
) do md "%%a" 2>nul


Or from a file

Code: Select all

@echo off
for /f "delims=" %%a in (file.txt) do md "%%a" 2>nul



The remaining task of copying newer files if the files in the image folder are older, is not something that is straight forward in batch. Date math can be done with a third party tool, or VB using WSH, or a batch function that you can find on the net. The date format in Windows is region specific so it's not straight forward.

alperefe
Posts: 9
Joined: 20 Jun 2012 21:22

Re: Batch moving using text file

#21 Post by alperefe » 02 Jul 2012 00:32

thanx for help foxidrive but things got even more complicated. here is the deal;

Code: Select all

@echo off

set dest=%cd%$Build$\
for /f "delims=" %%A in (folders.lst) do (
if not exist ..\$Build$\%~nx0 ( md $Build$ 2>Nul )
if not exist %%A ( md %%A 2>Nul )
xcopy "%%A" "%dest%" /E
)

:EOF


and this is my folder list

[list=]
Global
Dism_Logs\my_dism_logs
Image\sources\$oem$\$1\Windows
Image\sources\$oem$\$$\Setup\Scripts
Image\sources\$oem$\$$\System32\Drivers\etc
Image\sources\$oem$\$$\System32\Oem
Image\sources\$oem$\$$\System32\Web\Wallpaper
Mount\Boot
Mount\MountBasic
Mount\MountPremium
Mount\MountPro
Mount\MountStarter
Mount\MountUltimate
WDrivers
WUpdates
[/list]


The batch will create $build$ folder
then all the rest in the folder.lst
then move all those folders into $build$ folder along with the folder.lst and batch itself

and when the batch runs everytime it will check directories in the folder list and if there is a missing one it ll create it.
thanx for your time...again.

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

Re: Batch moving using text file

#22 Post by foxidrive » 02 Jul 2012 04:33

This code will do that too, if you have the text below it in file.txt

Code: Select all

@echo off
for /f "delims=" %%a in (file.txt) do md "%%a" 2>nul





Build\Global
Build\Dism_Logs\my_dism_logs
Build\Image\sources\$oem$\$1\Windows
Build\Image\sources\$oem$\$$\Setup\Scripts
Build\Image\sources\$oem$\$$\System32\Drivers\etc
Build\Image\sources\$oem$\$$\System32\Oem
Build\Image\sources\$oem$\$$\System32\Web\Wallpaper
Build\Mount\Boot
Build\Mount\MountBasic
Build\Mount\MountPremium
Build\Mount\MountPro
Build\Mount\MountStarter
Build\Mount\MountUltimate
Build\WDrivers
Build\WUpdates

alperefe
Posts: 9
Joined: 20 Jun 2012 21:22

Re: Batch moving using text file

#23 Post by alperefe » 02 Jul 2012 05:07

yes I ve noticed that too but as I said above my intention is to move the batch into $build$ folder. so when I run it next time, it will create the whole directory structure again whether it is missing or not.

ni.va
Posts: 6
Joined: 09 Mar 2011 05:56

Re: Batch moving using text file

#24 Post by ni.va » 08 Aug 2012 12:58

Hi
@alperefe: I just wanted to update the first post, So your Problem was a need to create a hole folder structure in destination... am I getting right??

Post Reply