Solved change ms dos script

May 28, 2018 at 10:28:30
Specs: Windows 7
I have the following script that moves stuff from C:\Downloads\BTP to S:\BTP DOWNLOADS and also from C:\Downloads to S:\DOWNLOADS

set SBTP="C:\CCTV DOWNLOADS\BTP DOWNLOADS"
set SCRCL="C:\CCTV DOWNLOADS\CHILTERN DOWNLOADS"

set DBTP="\\crcl.local\ApplicationData\BTPCCTVDownloads"
set DCRCL="S:\CCTV Downloads\Chiltern Downloads"
set DSAFE="S:\CCTV Downloads\safety dept\ICC SYNC"

xcopy %SBTP% %DBTP% /e /d
xcopy %STBP% %DSAFE% /e /d

xcopy %SCRCL% %DCRCL% /e /d

Im trying to amend it to look in C:\Downloads and if subfolder name starts with the letters BTP then I need it moving to S:\BTP DOWNLOADS and if not then I need the folder moving to S:\DOWNLOADS

Any ideas.

Thanks

message edited by GDB


See More: change ms dos script

Report •

✔ Best Answer
May 29, 2018 at 13:10:54
I cannot delete them if i've already moved them to another folder ;), problem solved i guess.

@echo off
PUSHD "C:\CCTV DOWNLOADS"
FOR "tokens=*" %%A IN ('DIR/B ^| FIND "BTP"') DO MOVE /Y "%%A" "\\crcl.local\ApplicationData\BTPCCTVDownloads"
FOR "tokens=*" %%A IN ('DIR/B') DO (
COPY /Y "%%A" "S:\CCTV Downloads\safety dept"
MOVE /Y "%%A" "S:\CCTV Downloads\Chiltern Downloads"
)

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1900MHz BiosModded



#1
May 29, 2018 at 01:41:00
what am i supposed to do with "%DBTP%"?

dir/B/OGN in a for loop then copy the %a to the destination folder (if BTP is in the file/folder name)

changes can be made afterwards without much trouble.

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1900MHz BiosModded


Report •

#2
May 29, 2018 at 02:11:13
nvm, i see.

will be making the script somewhere today

right now i understand you want to:
1) move C:\CCTV DOWNLOADS\BTP DOWNLOADS files if name contains "BTP" to "\\crcl.local\ApplicationData\BTPCCTVDownloads"
if they do not contain BTP then move them to "S:\CCTV Downloads\safety dept\ICC SYNC"
2) move all files from "C:\CCTV DOWNLOADS\CHILTERN DOWNLOADS" to "S:\CCTV Downloads\Chiltern Downloads"

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1900MHz BiosModded

message edited by hidde663


Report •

#3
May 29, 2018 at 02:31:21
::test-version, you may want to read it to check for mistakes
@echo off
::move the console to the destination line below
PUSHD "C:\CCTV DOWNLOADS\BTP DOWNLOADS"
::look for "BTP" in folder "C:\CCTV DOWNLOADS\BTP DOWNLOADS" & move them to "\\crcl.local\ApplicationData\BTPCCTVDownloads"
FOR "tokens=*" %%A IN ('DIR/B ^| FIND "BTP"') DO MOVE /Y "%%A" "\\crcl.local\ApplicationData\BTPCCTVDownloads"
::now that all "BTP" files are moved, move all remaining files to "S:\CCTV Downloads\safety dept\ICC SYNC"
FOR "tokens=*" %%A IN ('DIR/B') DO MOVE /Y "%%A" "S:\CCTV Downloads\safety dept\ICC SYNC"
::move the console to the destination line below
PUSHD "C:\CCTV DOWNLOADS\CHILTERN DOWNLOADS"
::move all files from "C:\CCTV DOWNLOADS\CHILTERN DOWNLOADS" to "S:\CCTV Downloads\Chiltern Downloads"
FOR "tokens=*" %%A IN ('DIR/B') DO MOVE /Y "%%A" "S:\CCTV Downloads\Chiltern Downloads"
::exit the batch script
exit/b

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1900MHz BiosModded


Report •

Related Solutions

#4
May 29, 2018 at 12:09:10
thanks and Im nearly there. Ive amended the script below and just need it checking and a bit adding to it if poss.

@echo off
PUSHD "C:\CCTV DOWNLOADS"
FOR "tokens=*" %%A IN ('DIR/B ^| FIND "BTP"') DO MOVE /Y "%%A" "\\crcl.local\ApplicationData\BTPCCTVDownloads"
FOR "tokens=*" %%A IN ('DIR/B') DO MOVE /Y "%%A" "S:\CCTV Downloads\Chiltern Downloads "

:: I also need a copy of the files that have been moved to "S:\CCTV Downloads\Chiltern Downloads " to be placed in S:\CCTV Downloads\safety dept ( THIS BIT I DONT KNOW HOW TO DO)

also if it dont do it after it moved the files from "C" to "S" drive I need the files in "C:\CCTV DOWNLOADS" deleted.

exit/b

Any Ideas

message edited by GDB


Report •

#5
May 29, 2018 at 13:10:54
✔ Best Answer
I cannot delete them if i've already moved them to another folder ;), problem solved i guess.

@echo off
PUSHD "C:\CCTV DOWNLOADS"
FOR "tokens=*" %%A IN ('DIR/B ^| FIND "BTP"') DO MOVE /Y "%%A" "\\crcl.local\ApplicationData\BTPCCTVDownloads"
FOR "tokens=*" %%A IN ('DIR/B') DO (
COPY /Y "%%A" "S:\CCTV Downloads\safety dept"
MOVE /Y "%%A" "S:\CCTV Downloads\Chiltern Downloads"
)

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1900MHz BiosModded


Report •

Ask Question