Search found 3967 matches

by aGerman
06 May 2021 14:10
Forum: DOS Batch Forum
Topic: Batch script to delete .txt files in all subfolders except one
Replies: 4
Views: 77

Re: Batch script to delete .txt files in all subfolders except one

Remove option /S from the DEL command. My fault.
The script will exclude all paths which contain string "\Documents\Folder1\Subfolder1". This integrates the exclusion of any subfolder structure underneath "Subfolder1". If this is not the intended behavior, I still don't get it.

Steffen
by aGerman
05 May 2021 15:25
Forum: DOS Batch Forum
Topic: How do i use RoboCopy where the destination is pinpointed with the name of a file?
Replies: 1
Views: 35

Re: How do i use RoboCopy where the destination is pinpointed with the name of a file?

Code: Select all

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST "%%i:\usb_stick.txt" robocopy "%%i:\." "E:\Data\USB Stick" /MIR
Just my guess.

Steffen
by aGerman
05 May 2021 15:19
Forum: DOS Batch Forum
Topic: Batch script to delete .txt files in all subfolders except one
Replies: 4
Views: 77

Re: Batch script to delete .txt files in all subfolders except one

I guess something like that should do the trick:

Code: Select all

for /f "delims=" %%i in ('dir /ad /b /s "%userprofile%\Documents"^|find /i /v "\Documents\Folder1\Subfolder1"') do del /f /s /q "%%i\*.xml"
Steffen
by aGerman
05 May 2021 14:54
Forum: DOS Batch Forum
Topic: A tool for managing multiple running dos batches
Replies: 8
Views: 92

Re: A tool for managing multiple running dos batches

My proposal: - open Task Manager - select the "Details" tab - right-click the header of an arbitrary column and click item "Select columns" - scroll the list and check "Command line" - click OK In the command lines of the cmd.exe processes you'll find the name of the Batch script each. I guess it'll...
by aGerman
26 Apr 2021 10:54
Forum: DOS Batch Forum
Topic: Taskkill %0
Replies: 6
Views: 247

Re: Taskkill %0

It's a little problematic due to the quotes around the own path of the script. I'd probably use a filtered output of tasklist to get the PID. As long as the title still doesn't contain the " - " you can use this snippet in the same script that later on calls file1-N. set me=%0 set me=%me:\=\\% for /...
by aGerman
25 Apr 2021 07:25
Forum: DOS Batch Forum
Topic: output computer, AD User
Replies: 4
Views: 204

Re: output computer, AD User

"dsget succeeded" will be tokenized where only "dsget" is assigned to %%u. Maybe just use another FIND or FINDSTR filter, like this:

Code: Select all

    for /F "skip=1 tokens=1,2" %%u in ('dsquery user -samid %%f^|dsget user -display^|findstr /ivc:"dsget succeeded"') do (
Steffen
by aGerman
19 Apr 2021 16:19
Forum: DOS Batch Forum
Topic: Replace a specific character in CSV
Replies: 3
Views: 234

Re: Replace a specific character in CSV

Pretty similar: https://www.dostips.com/forum/viewtopic.php?f=3&t=10035 @if (0)==(0) echo off &setlocal set "infile=test.csv" set "outfile=out.csv" set "separator=;" cscript //nologo //e:jscript "%~fs0" "%infile%" "%outfile%" "%separator%" goto :eof @end var oFSO = new ActiveXObject('Scripting.FileS...
by aGerman
19 Apr 2021 12:57
Forum: DOS Batch Forum
Topic: Get all column data in csv file (from column 100 to column 110, 150)
Replies: 12
Views: 434

Re: Get all column data in csv file (from column 100 to column 110, 150)

I downloaded your CSV file with two different browsers in order to verify that the lines actually end with a single carriage return (0D if you observe the file content in a HEX editor). If this is the same in your real CSV files, it will probably never work. Can you confirm that this is true? On Win...
by aGerman
16 Apr 2021 09:29
Forum: DOS Batch Forum
Topic: Get all column data in csv file (from column 100 to column 110, 150)
Replies: 12
Views: 434

Re: Get all column data in csv file (from column 100 to column 110, 150)

If this is not a secret, could you copy your updated script into your reply?

Steffen
by aGerman
16 Apr 2021 00:29
Forum: DOS Batch Forum
Topic: Get all column data in csv file (from column 100 to column 110, 150)
Replies: 12
Views: 434

Re: Get all column data in csv file (from column 100 to column 110, 150)

I can ensure you that the Java version has nothing to do with it. The script uses JScript (which is the Windows-specific implementation of ECMAScript commonly known as JavaScript).

Steffen
by aGerman
15 Apr 2021 00:09
Forum: DOS Batch Forum
Topic: Get all column data in csv file (from column 100 to column 110, 150)
Replies: 12
Views: 434

Re: Get all column data in csv file (from column 100 to column 110, 150)

Rather don't put the file directly into the C:\ root because you might have restricted access to create the output file. Besides of that it should work though. At least it worked for me. Insert a PAUSE between the CSCRIPT and GOTO lines to keep the window open. Maybe you get an error message that he...
by aGerman
14 Apr 2021 10:22
Forum: DOS Batch Forum
Topic: Get all column data in csv file (from column 100 to column 110, 150)
Replies: 12
Views: 434

Re: Get all column data in csv file (from column 100 to column 110, 150)

I'd probably use the aid of JScript in a Batch-hybrid. *.bat @if (0)==(0) echo off &setlocal set "infile=test.csv" set "outfile=out.csv" set "separator=," cscript //nologo //e:jscript "%~fs0" "%infile%" "%outfile%" "%separator%" goto :eof @end var oFSO = new ActiveXObject('Scripting.FileSystemObject...
by aGerman
10 Apr 2021 10:59
Forum: DOS Batch Forum
Topic: Rename all files in all subfolders except some folders
Replies: 2
Views: 486

Re: Rename all files in all subfolders except some folders

You just need a filter. FINDSTR has an option /V for exclusion.

Code: Select all

for /f "delims=" %%G in ('dir /ad /b "MainFolder\*"^|findstr /vxi /c:"folder x" /c:"folder y"') do (
  for /r %%H in ("MainFolder\%%G\*.txt") do REN "%%H" "%%~nH.old"
)
"folder x" and "folder y" are excluded.

Steffen
by aGerman
30 Mar 2021 16:02
Forum: DOS Batch Forum
Topic: read sfc output
Replies: 4
Views: 839

Re: read sfc output

I'm not sure if that is something you can make use of. However, sfc already writes to the cbs.log file. You just have to filter the entries that contain the [SR] tag.
https://docs.microsoft.com/en-us/troubl ... le-entries

Steffen
by aGerman
29 Mar 2021 11:37
Forum: DOS Batch Forum
Topic: Howto: Renaming of files in a folder
Replies: 2
Views: 731

Re: Howto: Renaming of files in a folder

Command line in a cmd prompt:

Code: Select all

for %i in ("[NLRC]*.pdf") do @for /f "tokens=1*" %j in ("%~i") do @ren "%~i" "%~k"
In a Batch script you would have to double all percent signs.

Steffen