Search found 427 matches

by SIMMS7400
09 Apr 2019 06:58
Forum: DOS Batch Forum
Topic: How to sort file contents based on pattern?
Replies: 4
Views: 226

Re: How to sort file contents based on pattern?

Ah yes, very simple using the tokens.

Code: Select all

FOR /F "tokens=2 delims=_." %%A IN ('FINDSTR /c:"%OUTBOX_BIN%%NAME%_" %FILE%') DO (
    SET "NUM=%%~A"
    IF !NUM! GTR !MAXNUM! SET "MAXNUM=!NUM!" & SET "MAXFILE=%NAME%_!MAXNUM!.log"
)
THanks!
by SIMMS7400
09 Apr 2019 01:38
Forum: DOS Batch Forum
Topic: How to sort file contents based on pattern?
Replies: 4
Views: 226

How to sort file contents based on pattern?

Hi Folks - I have a text file that looks like such: outbox/logs/PLAN - Custom_8001.log outbox/logs/PLAN - Custom_242.log outbox/logs/PLAN - Custom_243.log outbox/logs/PLAN - Custom_244.log outbox/logs/PLAN - Custom_245.log outbox/logs/PLAN - Custom_246.log outbox/logs/PLAN - Custom_40.log outbox/log...
by SIMMS7400
03 Apr 2019 17:42
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 662

Re: Lag methodology

Hi Antonio -

I see the code you posted on the new thread is a bit different than the one above - which one should be used?

Thank you!
by SIMMS7400
01 Apr 2019 18:46
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 662

Re: Lag methodology

I would like to present a simpler approach: @echo off setlocal EnableDelayedExpansion set /P "YYYYMMDD=Enter date in YYYYMMDD format: " set /P "days=Enter number of days: " set /A "DD=100+(D=YYYYMMDD%%100), YYYYMM=YYYYMMDD/100, MM=100+(M=YYYYMM%%100), YYYY=YYYYMM/100 for /L %%i in (1,1,%days%) do (...
by SIMMS7400
18 Mar 2019 18:16
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 662

Re: Lag methodology

Hi All -

Thank for the links! I'm been playing around with that but can't seem to get anything worth that would be dynamic enough. Was hoping this was a quick hit. Does anyone mind sharing an example I could extrapolate on?

Gracias!
by SIMMS7400
14 Mar 2019 05:14
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 662

Lag methodology

Hi Folks - I have a unique need to implement a lag type of methodology. For instance, I have a date variable set as such: SET "DATEVAR=31-Jan-18" I also need to set (4) additional variable that lag 4 days. For instance: SET "DATEVAR1=30-Jan-18" SET "DATEVAR2=29-Jan-18" SET "DATEVAR3=28-Jan-18" SET "...
by SIMMS7400
23 Jan 2019 16:05
Forum: DOS Batch Forum
Topic: Manipulating a variable
Replies: 2
Views: 246

Re: Manipulating a variable

I played around and got this to work, but not sure if it's the most efficient? SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com" SET "SEARCH=test" ECHO "%CLOUD_URL%" | FINDSTR /C:"%SEARCH%" >nul 2>&1 && ( SET "FLAG=T" ) IF DEFINED FLAG FOR /F "tokens=1,3 delims=-" %%A IN ("%CLOUD_UR...
by SIMMS7400
23 Jan 2019 15:45
Forum: DOS Batch Forum
Topic: Manipulating a variable
Replies: 2
Views: 246

Manipulating a variable

Hi Folks - I have a variable defined as such: SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com" What I need to do is if the variable above does not have the string "test" in it, I need to add it. Like such: SET "CLOUD_URL=https://planning-test-z552xxx1.pbcs.us2.oraclecloud.com" And ...
by SIMMS7400
13 Jan 2019 14:57
Forum: DOS Batch Forum
Topic: robocopy help please
Replies: 5
Views: 450

Re: robocopy help please

Damn Millennials...

Please try a few different things and come back with your results.
by SIMMS7400
09 Jan 2019 19:54
Forum: DOS Batch Forum
Topic: FOR LOOP Question - Delimiters
Replies: 2
Views: 313

FOR LOOP Question - Delimiters

Hi Folks - I have what I believe is a very easy question. If I have a file with a line: ,Total Tire Centers And my FOR LOOP looks like this: FOR /F "USEBACKQ TOKENS=1-2 DELIMS=," %%A IN ("%CNTRL_FILE%") DO ECHO "%%~A" "%%~B" Why does "%%~A" return "Total Tire Centers" instead of just ""? Ideally, I ...
by SIMMS7400
21 Dec 2018 17:12
Forum: DOS Batch Forum
Topic: Advice Question - how to check to see if file has already been ran?
Replies: 3
Views: 369

Advice Question - how to check to see if file has already been ran?

Hi Folks - I have a process that consumes data files from a specific directory and then loads into a target application. However, after the load, the files are not moved/archived. Therefore, when I access the directory with each call to the function, the same file is read into the for loop again obv...
by SIMMS7400
12 Dec 2018 13:33
Forum: DOS Batch Forum
Topic: 7zip issues
Replies: 2
Views: 333

Re: 7zip issues

Thanks Squash.

I ended up making an exclusion list and passing that in instead - works fine now!

Thank you!

Best,
C
by SIMMS7400
12 Dec 2018 11:45
Forum: DOS Batch Forum
Topic: 7zip issues
Replies: 2
Views: 333

7zip issues

Hi Folks - I'm banging my head against the wall on trying to exclude a certain directory from my archive process. SET "ASCENDDRIVE3=\\server.client.com\TM1_CDM_Data\Target" SET "PDD_ZIP_PATH=%ASCENDDRIVE3%\Archive\PDD_TO_DATAHUB_OB_FILES_%DATETIME%.zip" CALL "7z.exe" a -tzip "%PDD_ZIP_PATH%" "%ASCEN...
by SIMMS7400
10 Dec 2018 02:54
Forum: DOS Batch Forum
Topic: Batch subtraction with leading zero
Replies: 2
Views: 327

Re: Batch subtraction with leading zero

HI Squash -

Ah yes, very easy!

This solves for my issue, but looks awfully clunky.

Code: Select all

SET "ENDYEAR=%DATAFILENAME:~-6%"
SET "ENDYEAR=%ENDYEAR:~0,2%"
SET /A "STARTYEAR=1%ENDYEAR%-1"
SET "STARTYEAR=%STARTYEAR:~1,3%"
SET "STARTPOV=Sep-%STARTYEAR%" & SET "ENDPOV=Oct-%ENDYEAR%"
by SIMMS7400
09 Dec 2018 19:01
Forum: DOS Batch Forum
Topic: Batch subtraction with leading zero
Replies: 2
Views: 327

Batch subtraction with leading zero

Hi Folks - I am building a process that requires me to extract the year from a file name. The file name is as follows: hp_profitandloss_extract_FY08.csv The year will always be the last string preceeding the .csv. I need to extract the year and set it in a variable and also set another variable that...