Search found 3500 matches

by aGerman
17 Jul 2019 15:45
Forum: DOS Batch Forum
Topic: simple script
Replies: 1
Views: 51

Re: simple script

Remove all spaces around the = in every SET statement.

Steffen
by aGerman
16 Jul 2019 09:47
Forum: DOS Batch Forum
Topic: create a folder based on filename
Replies: 2
Views: 57

Re: create a folder based on filename

Just use !folname:~0,4!.

Steffen
by aGerman
30 Jun 2019 07:35
Forum: DOS Batch Forum
Topic: JREN.BAT v2.8 - Rename files/folders using regular expressions
Replies: 56
Views: 30336

Re: JREN.BAT v2.8 - Rename files/folders using regular expressions

Try to change the console code page to UTF-8 (65001) first.

Code: Select all

@echo off &setlocal
chcp 65001
for /f "delims=, tokens=1,2" %%A in (1.csv) do ren "%%~B" "%%~A"
Steffen
by aGerman
30 Jun 2019 07:22
Forum: DOS Batch Forum
Topic: [Resolved] Moving incrementally named files to three different directories, evenly
Replies: 2
Views: 297

Re: Moving sequentially named files to three different directories, evenly

Not sure what "sequentially named" and "image files" means in particular because you didn't provide any example. If you are only looking for the math, then it's quite easy. for /f %%i in ('dir /a-d /b *.jpg^|find /c /v ""') do set /a "third=%%i/3, remaining=%%i-2*third" echo %third% %third% %remaini...
by aGerman
21 Jun 2019 14:30
Forum: DOS Batch Forum
Topic: send email via batch
Replies: 3
Views: 560

Re: send email via batch

https://social.technet.microsoft.com/wi ... tches.aspx
I don't see any command line option to send an email, sorry.

Steffen
by aGerman
20 Jun 2019 12:59
Forum: DOS Batch Forum
Topic: Animated loading screen
Replies: 2
Views: 618

Re: Animated loading screen

Most of those "loading screens" are just a waste of time because - either there is nothing to load - or they are synchronously executed If you have some code that really takes time and you want to let the user know, then you have to animate it asynchronously while your actual task is executed. @echo...
by aGerman
16 Jun 2019 14:47
Forum: DOS Batch Forum
Topic: BATCH DOES NOT START
Replies: 1
Views: 494

Re: BATCH DOES NOT START

In a command line FOR variables have one preceding percent sign (e.g. %a) while in a Batch script they need to have two (e.g. %%a).

Steffen
by aGerman
12 Jun 2019 09:45
Forum: DOS Batch Forum
Topic: Batch file with config file
Replies: 2
Views: 652

Re: Batch file with config file

You can't execute a txt file. And since you didn't say anything about its content we don't even know whether it contains any executable script code. If it contains Batch code then rename it with extension bat and call it.

Steffen
by aGerman
10 Jun 2019 16:29
Forum: DOS Batch Forum
Topic: Copying a file from a folder with today's date to another folder.
Replies: 2
Views: 631

Re: Copying a file from a folder with today's date to another folder.

You can use the wmic command to work around localized date formats.

Code: Select all

@echo off &setlocal
for /f %%i in ('wmic os get localdatetime /value') do for /f %%j in ("%%i") do set %%j
copy /y "C:\monitoring\%localdatetime:~4,4%%localdatetime:~,4%\hg200T.csv" "C:\warning\excel\stream\"
Steffen
by aGerman
10 Jun 2019 10:38
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 682

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Check your paths for typos, make sure there are no characters in the folder names that are not supported (preferably use ASCII only), make sure the paths exist (e.g. don't mess up "C:\My Documents" and "%userprofile%\Documents").

Steffen
by aGerman
10 Jun 2019 07:36
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 682

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

I created folder "C:\My Documents" and subfolders "barclassifiedfoo", "foobar", and "fooclassifiedbar" inside of it. Then I run the above code. It created "subfolder1", "subfolder2", and "subfolder3" in both "barclassifiedfoo" and "fooclassifiedbar" as expected.

Steffen
by aGerman
10 Jun 2019 07:00
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 682

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Untested: @echo off setlocal set "parentfolder=C:\My Documents" set "pattern=*classified*" pushd "%parentfolder%" for /F "tokens=*" %%G in ('dir "%pattern%" /A:D /B') do ( if not exist "%%G\subfolder1" md "%%G\subfolder1" if not exist "%%G\subfolder2" md "%%G\subfolder2" if not exist "%%G\subfolder3...
by aGerman
10 Jun 2019 06:17
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 682

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Try

Code: Select all

md "%%~fG\subfolder1"
You may have to PUSHD to the parent folder first. Otherwise there is a risk that modifier ~f doesn't expand to the right directory.

Steffen
by aGerman
10 Jun 2019 06:06
Forum: DOS Batch Forum
Topic: CONVERTCP.exe - Convert text from one code page to another
Replies: 84
Views: 33435

Re: CONVERTCP.exe - Convert text from one code page to another

Most of the current command line utilities don't support Virtual Terminal processing yet. In this case ANSI escape sequences are not used to control the console output and their textual expressions get printed to the screen. Example using an old version: >nul chcp 65001 echo +ABsAWw-93;42m+JYgliCWIJ...
by aGerman
04 Jun 2019 11:46
Forum: DOS Batch Forum
Topic: Check if a batch completed successfully (and was not closed by the user.
Replies: 8
Views: 940

Re: Check if a batch completed successfully (and was not closed by the user.

You said it's sequential. If the script failed or was interrupted, would you be able to begin somewhere in the middle of the sequences? For me it's all like crystal-ball gazing because I don't have any context. So, I still don't understand the sense of a flag. My understanding: caller.bat @echo off ...