Solved amend a script to come up with another question

June 15, 2018 at 10:04:42
Specs: Windows 7
Ladies and Gents

Im looking for a slight amendment to the script if poss but dont know how to do it.

I need it to create a subfolder and ask if it a BTP download Y/N. If I push YES I need it to move to destination directory 1 as per script but If I push NO I need it to ask me if it a chiltern download with Y/N option and if YES I need it moved to destination directory 2 .

If I then push NO can I get it to move the folder to "D" drive so I can burn it to DVD and then remove all files and subfolders as per script.

@echo off
setlocal EnableDelayedExpansion

rem Define folder paths
set BaseDir=X:\DOWNLOADS
set DestDir1=X:\BTP DOWNLOADS
set DestDir2=X:\CHILTERNDOWNLOADS

rem Quit if no files in download area to process
set Empty=Y
for %%A in ("%BaseDir%\*.*") do set Empty=N
if "%Empty%" EQU "Y" (
    echo No new files to process, quitting.
    exit /b
)

rem Prompt for reference number
set RefNum=
set /P "RefNum=Enter reference number (blank to exit):"

rem If none entered, exit script
if "%RefNum%" EQU "" exit /b

rem Make a subfolder for the reference number
md "%BaseDir%\%RefNum%"

rem Move all files to new subfolder
move "%BaseDir%\*.*" "%BaseDir%\%RefNum%"

rem Ask if BTS download to determine where to move the new folder
choice /C YN /M "Is this a BTP download (Y/N)?"
if !ERRORLEVEL! EQU 1 (
  move "%BaseDir%\%RefNum%" "%DestDir1%"
) else (
  move "%BaseDir%\%RefNum%" "%DestDir2%"
)

rem Remove ALL files from base download folder
del /s /q "%BaseDir%\*.*"

rem Remove any remaining subfolders too
for /d %%A in ("%BaseDir%\*.*") do rd /s /q "%%~A"


See More: amend a script to come up with another question

Reply ↓  Report •

#1
June 15, 2018 at 10:35:01
please make a backup & try this:

@echo off&setlocal EnableDelayedExpansion
set BaseDir=X:\DOWNLOADS
set DestDir1=X:\BTP DOWNLOADS
set DestDir2=X:\CHILTERNDOWNLOADS
set Empty=Y
for %%A in ("%BaseDir%\*.*") do set Empty=N
if "%Empty%" EQU "Y" (
echo No new files to process, quitting.
exit /b
)
set RefNum=
set /P "RefNum=Enter reference number (blank to exit):"
if "%RefNum%" EQU "" exit /b
mkdir "%BaseDir%\%RefNum%"
move "%BaseDir%\*.*" "%BaseDir%\%RefNum%"
choice /C YN /M "Is this a BTP download (Y/N)?"
if !ERRORLEVEL! EQU 1 (
move "%BaseDir%\%RefNum%" "%DestDir1%"
) else (
choice /c yn /m "chiltern download (Y/N)?"
if !ERRORLEVEL! EQU 1 (
move "%BaseDir%\%RefNum%" "%DestDir2%"
) else (
move "%BaseDir%\%RefNum%" "D:\"
rmdir /s /q "%BaseDir%"
)
)


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

message edited by hidde663


Reply ↓  Report •

#2
June 15, 2018 at 11:14:38
Nearly there

It asking me correctly if it a BTP or Chiltern download but when I select NO for both its deleting the folder CCTV DOWNLOADS.

Maybe I wasnt clear but if both answers are NO I need the subfolder in X:\downloads to be moved to "D" drive so I can just select "BURN TO DISK"

Apologies

Apologies


Reply ↓  Report •

#3
June 15, 2018 at 12:03:15
✔ Best Answer
something like this?(it should delete CCTV DOWNLOADS at the very end of the script):

@echo off&setlocal EnableDelayedExpansion
set BaseDir=X:\DOWNLOADS
set DestDir1=X:\BTP DOWNLOADS
set DestDir2=X:\CHILTERNDOWNLOADS
set Empty=Y
for %%A in ("%BaseDir%\*.*") do set Empty=N
if "%Empty%" EQU "Y" (
echo No new files to process, quitting.
exit /b
)
set RefNum=
set /P "RefNum=Enter reference number (blank to exit):"
if "%RefNum%" EQU "" exit /b
mkdir "%BaseDir%\%RefNum%"
move "%BaseDir%\*.*" "%BaseDir%\%RefNum%"
choice /C YN /M "Is this a BTP download (Y/N)?"
if !ERRORLEVEL! EQU 1 (
move "%BaseDir%\%RefNum%" "%DestDir1%"
) else (
choice /c YN /m "chiltern download (Y/N)?"
if !ERRORLEVEL! EQU 1 (
move "%BaseDir%\%RefNum%" "%DestDir2%"
) else (
pushd "D:\"
if not exist "DOWNDLOADS" mkdir "DOWNLOADS"
move "%BaseDir%\%RefNum%" "D:\DOWNLOADS"
popd
)
)
echo DONE...
choice /c yn /m "delete %basedir%?"
if !ERRORLEVEL! EQU 1 (
rmdir /s /q "%BaseDir%"
)

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

message edited by hidde663


Reply ↓  Report •

Related Solutions

#4
June 16, 2018 at 01:39:58
Thanks for that.

It works apart from when the folder moves to "D" drive as they dont appear in the folder.

What im trying to do is move them to "D" drive where you normaly drag files over to before you click on "BURN TO CD" Im ok with clicking on "burn to disk " I just need it to move the folder into the "D" drive automatically .

This is to only happen when I click on NO for questions if a BTP or Chiltern download.


Reply ↓  Report •

#5
June 16, 2018 at 15:44:15
I've added a few lines to the script in post #3

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


Reply ↓  Report •

#6
June 17, 2018 at 02:12:38
Many thanks for all the help

Reply ↓  Report •

Ask Question