Batch moving using text file
Moderator: DosItHelp
Re: Batch moving using text file
There are two versions of the list.txt file format there, and two batch files.
Which one are you using?
Which one are you using?
Re: Batch moving using text file
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.
thanx in advance.
Re: Batch moving using text file
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.
Re: Batch moving using text file
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.
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.
Re: Batch moving using text file
This should create the folders if they are missing.
Or from a file
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.
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.
Re: Batch moving using text file
thanx for help foxidrive but things got even more complicated. here is the deal;
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.
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.
Re: Batch moving using text file
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
Re: Batch moving using text file
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.
Re: Batch moving using text file
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??
@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??