Solved Bat script to auto upload to gs

February 18, 2020 at 02:59:18
Specs: Windows 10
I'm trying to set up a system/bat script that reads all the folders in a network location drive. then save the list of folders. this is what i have so far: dir /D/Ad-s T:\ > N:\_backup_test\Log.txt
I then want to insert each line in the log into the pre-written script i already have. this is the part im having difficulties with

thanks


See More: Bat script to auto upload to gs

Reply ↓  Report •

✔ Best Answer
March 2, 2020 at 21:45:30
As far as I can tell, this might approach:
::----- begin test script a.bat
@echo off & setlocal
for /f "tokens=*" %%a in (M:\_backup_test\Log.txt) do (
echo gsutil -m cp -n -r Z:\%%a gs://z_backup/Z$/Z_NEW/Z$/Z$/
gsutil -m cp -n -r Z:\%%a gs://z_backup/Z$/Z_NEW/Z$/Z$/
)
:: -------- end script
The echo is just to see what's being executed on what.


#1
February 18, 2020 at 03:24:51
the way it saves each filename is [filename1]
[filename2]
[filename3]

Reply ↓  Report •

#2
February 18, 2020 at 21:51:23
@echo off & setlocal
pushd X:\Y
dir /b /s>N:\_backup_test\Log.txt

Reply ↓  Report •

#3
March 2, 2020 at 04:04:31
That definitely helped. here is what i have now.

This makes a log.txt file with all the names of the folders.
dir /D/Ad-s Z:\ > M:\_backup_test\Log.txt

This reads the log.
type M:\_backup_test\Log.txt

this is the next bit that i need help on, everything outside of the () works but i need a way to insert the name inside the [ ] into the "Z:\ " one at a time. run then repeat till it gets the end.

gsutil -m cp -n -r Z:\(insert text in"[ ]") gs://z_backup/Z$/Z_NEW/Z$/Z$/

For example:
List:
[ABC101_Test1]
[ABC102_Test2]
[ABC10n_Testn]

gsutil -m cp -n -r Z:\ABC101_Test1 gs://z_backup/Z$/Z_NEW/Z$/Z$/
gsutil -m cp -n -r Z:\ABC102_Test2 gs://z_backup/Z$/Z_NEW/Z$/Z$/
gsutil -m cp -n -r Z:\ABC10n_Testn gs://z_backup/Z$/Z_NEW/Z$/Z$/


Reply ↓  Report •

Related Solutions

#4
March 2, 2020 at 21:45:30
✔ Best Answer
As far as I can tell, this might approach:
::----- begin test script a.bat
@echo off & setlocal
for /f "tokens=*" %%a in (M:\_backup_test\Log.txt) do (
echo gsutil -m cp -n -r Z:\%%a gs://z_backup/Z$/Z_NEW/Z$/Z$/
gsutil -m cp -n -r Z:\%%a gs://z_backup/Z$/Z_NEW/Z$/Z$/
)
:: -------- end script
The echo is just to see what's being executed on what.

Reply ↓  Report •

#5
March 30, 2020 at 04:33:26
This is the message i get, %%a was unexpected at this time. it doesnt appear to be reading the file M:\__Test\Test.txt

I have the list of files i want to upload but

C:\Users\matthew.r\AppData\Local\Google\Cloud SDK>@echo off & setlocal
for /f "tokens=*" %%a in (M:\__Test\Test.txt) do (
%%a was unexpected at this time.
echo gsutil -m cp -n -r X:\ %%a gs://t_drive_backup/T$/
gsutil -m cp -n -r X:\ %%a gs://t_drive_backup/T$/
gsutil -m cp -n -r X:\ %%a gs://t_drive_backup/T$/
Copying file://X:\ABB108_Mitral_Valve\Video\Heart_Blood_Cycle_Blood_Flow.mov [Content-Type=video/quicktime]...
Copying file://X:\ABB108_Mitral_Valve\Video\SC010_Body_intro.mov [Content-Type=video/quicktime]...
Copying file://X:\ABB108_Mitral_Valve\Video\SC005_MitClip_Intro_B.mov [Content-Type=video/quicktime]...
Resuming upload for file://X:\ABB108_Mitral_Valve\Video\SC005_MitClip_Intro_B.mov
==> NOTE: You are uploading one or more large file(s), which would run
significantly faster if you enable parallel composite uploads. This
feature can be enabled by editing the
"parallel_composite_upload_threshold" value in your .boto
configuration file. However, note that if you do this large files will
be uploaded as `composite objects
<https://cloud.google.com/storage/docs/composite-objects>`_,which
means that any user who downloads such objects will need to have a
compiled crcmod installed (see "gsutil help crcmod"). This is because
without a compiled crcmod, computing checksums on composite objects is
so slow that gsutil disables downloads of composite objects.


Reply ↓  Report •

#6
March 30, 2020 at 23:01:26
Only thing so far is that space. Should not be there:
echo gsutil -m cp -n -r X:\ %%a gs://t_drive_backup/T$/
gsutil -m cp -n -r X:\ %%a gs://t_drive_backup/T$/

this,maybe:
echo gsutil -m cp -n -r X:\%%a gs://t_drive_backup/T$/
gsutil -m cp -n -r X:\%%a gs://t_drive_backup/T$/

But that shouldn't have caused problem. Still not sure. Needing copy/sample of:
M:\__Test\Test.txt
One line should suffice.
May need quotes around %%a if it has spaces or other disruptors:
gsutil -m cp -n -r X:"\%%a" gs://t_drive_backup/T$/
or use short-name notation:
gsutil -m cp -n -r X:\%%~sa gs://t_drive_backup/T$/

message edited by nbrane


Reply ↓  Report •

Ask Question