Search found 29 matches

by ALbino
15 Dec 2014 22:43
Forum: DOS Batch Forum
Topic: Working with a mapped directory
Replies: 8
Views: 6224

Re: Working with a mapped directory

@echo off

It's your friend :P
by ALbino
12 Dec 2014 13:41
Forum: DOS Batch Forum
Topic: Batch File First day and last day of current month
Replies: 10
Views: 21455

Re: Batch File First day and last day of current month

foxidrive wrote:
ALbino wrote:Since there's only 12 possibilities, it's really not that big of a deal:

It's inelegant, but it works :)


Yep. As long as the OP is in the same region of the world as you, or uses the same date format. :D


Hah, good point, hadn't thought of that! :D
by ALbino
12 Dec 2014 01:31
Forum: DOS Batch Forum
Topic: Batch File First day and last day of current month
Replies: 10
Views: 21455

Re: Batch File First day and last day of current month

Since there's only 12 possibilities, it's really not that big of a deal: @echo off set FirstDay=01 set Month=%date:~4,2% set Year=%date:~10,4% if %Month%==01 set LastDay=31 & goto foundate if %Month%==02 set LastDay=28 & goto foundate if %Month%==03 set LastDay=31 & goto foundate if %Mon...
by ALbino
11 Dec 2014 23:45
Forum: DOS Batch Forum
Topic: Batch File First day and last day of current month
Replies: 10
Views: 21455

Re: Batch File First day and last day of current month

Since the first and last day of the month are always the same, why not just hardcode them? You don't need to perform a calculation to know that the first and last day of December are the 1st and 31st.
by ALbino
11 Dec 2014 15:02
Forum: DOS Batch Forum
Topic: Shutdown Batch
Replies: 16
Views: 13964

Re: Shutdown Batch

You don't even need to type "off" if you're going to just have a separate file named off.bat:

Code: Select all

@echo off

shutdown -a
echo Shutdown was canceled.
by ALbino
10 Dec 2014 22:32
Forum: DOS Batch Forum
Topic: Shutdown Batch
Replies: 16
Views: 13964

Re: Shutdown Batch

You need to make time into a variable by putting %'s around it. However, %Time% is an already defined Windows variable, so you should probably call it something ShutdownTime:

Code: Select all

@echo off
set /a ShutdownTime=%1*60
shutdown -s -t %ShutdownTime%


Hope this helps.
by ALbino
05 Dec 2014 16:35
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 7712

Re: For Loop Question

Ah, short filenames. That makes sense. Thanks for the feedback and the help guys. Much appreciated!
by ALbino
04 Dec 2014 22:34
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 7712

Re: For Loop Question

Just an update: I've switched from using ~'s to using +'s and dir /b *+*.txt works fine, so I'm going to go with that. Though I'm still not sure why ~'s don't work.
by ALbino
04 Dec 2014 21:23
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 7712

Re: For Loop Question

I think maybe the tilde (~) is the problem. Just opening a command prompt and using any other character seems to work, but when I use *~* this is what happens: C:\test\textfiles>dir /b *~*.txt Filename~0001.txt Filename-0002__0_mins_2_secs.txt But if I just search for *_* or *-* or *2* it's fine: C:...
by ALbino
04 Dec 2014 21:09
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 7712

Re: For Loop Question

change your file mask. Dir /b *~*.txt That's the first thing I tried, but it didn't work. Here's is my line: for /F "tokens=1,2 delims=~" %%G in ('dir /b *~*.txt') do ( Here's the output from a directory with one renamed file and one that has yet to be renamed... Input files: Filename~000...
by ALbino
04 Dec 2014 20:05
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 7712

For Loop Question

Hey guys, I have a little loop where I search for all .txt files and pull a number from them before doing a calculation on it and renaming the file. The original filenames look like: Filename~0001.txt I am then pulling 0001, performing a calculation and renaming them to: Filename-0001__0_mins_1_secs...
by ALbino
31 Oct 2014 23:30
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14530

Re: Checking for several different strings in a variable

I'll read up on it, thank you Antonio!
by ALbino
31 Oct 2014 21:58
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14530

Re: Checking for several different strings in a variable

vbscript comes with regular expression. Set objFSO=CreateObject("Scripting.FileSystemObject") Set regex = New RegExp With regex .Pattern = "example|this.*that" .IgnoreCase = True .Global = False End With inputFile = WScript.Arguments(0) Set objFile = objFSO.OpenTextFile(inputFil...
by ALbino
31 Oct 2014 21:57
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14530

Re: Checking for several different strings in a variable

What sort of "dealing with strings" information are you looking for? Because we have m and m which should cover a good chunk of basic string coding. Thank you, I appreciate the link! Your example works with single phrases, but I'm unsure how to use multiple ones. For example, if I do this...
by ALbino
31 Oct 2014 20:56
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14530

Re: Checking for several different strings in a variable

Good to know, thank you.

Can anybody recommend a good comprehensive walk through of dealing with strings? This is what I've been using, but in their examples they rarely show the eventual result:

http://ss64.com/nt/findstr.html