Search found 3748 matches

by Squashman
21 Jun 2018 14:46
Forum: DOS Batch Forum
Topic: Can't get batch file to input commands into Diskpart
Replies: 1
Views: 12

Re: Can't get batch file to input commands into Diskpart

The diskpart commands can be placed in a text file (one command per line) and used as an input file to diskpart.exe:

DiskPart.exe < myscript.txt

or

diskpart /s scriptname.txt
by Squashman
21 Jun 2018 14:38
Forum: DOS Batch Forum
Topic: Creatively stupid ways to rename files with spaces to underscores
Replies: 9
Views: 79

Re: Creatively stupid ways to rename files with spaces to underscores

I gave the doskey macro a try. This was my results. C:\Users\Squashman\spaces>dir /b fu bar 1.txt s p aces.txt C:\Users\Squashman\spaces>renSpaceTo_ *.txt C:\Users\Squashman\spaces>dir /b fu_bar_1.txt s_p aces.txt C:\Users\Squashman\spaces>doskey /macros renSpaceTo_=cmd /c "@(call &for %F in ($*) do...
by Squashman
21 Jun 2018 14:24
Forum: DOS Batch Forum
Topic: Creatively stupid ways to rename files with spaces to underscores
Replies: 9
Views: 79

Re: Creatively stupid ways to rename files with spaces to underscores

Actually the simple FOR statement uses some form of buffering. If all of the matching files fit within the buffer, then newly appearing file names will never be processed. But if there are a lot of files, then the first set of files that fit in the buffer are processed. Then when the next set of fi...
by Squashman
21 Jun 2018 11:39
Forum: DOS Batch Forum
Topic: Need help deleting the second line in all csvs in a folder
Replies: 7
Views: 32

Re: Need help deleting the second line in all csvs in a folder

Something like this should work.

Code: Select all

@echo off

set "_outputfolder=D:\A Folder\A Subfolder\Test Folder"
echo %_outputfolder%
pushd "%_outputfolder%"
for %%G in ("*.CSV") do (
	findstr /v /r /c:"^-*|-*" "%%~G">temp.csv.txt
	move "temp.csv.txt" "%%~G"
)
delete temp.csv.txt
popd
by Squashman
21 Jun 2018 10:06
Forum: DOS Batch Forum
Topic: Need help deleting the second line in all csvs in a folder
Replies: 7
Views: 32

Re: Need help deleting the second line in all csvs in a folder

capella wrote:
21 Jun 2018 10:04
That's correct.
Then it could be as simple as a reverse match on a simple regular expression using the FINDSTR command.
by Squashman
21 Jun 2018 10:03
Forum: DOS Batch Forum
Topic: Need help deleting the second line in all csvs in a folder
Replies: 7
Views: 32

Re: Need help deleting the second line in all csvs in a folder

So the second line is always a bunch of dashes with the delimiter?
by Squashman
21 Jun 2018 09:20
Forum: DOS Batch Forum
Topic: DOS Batch script - Variable for current system time plus 2 minutes?
Replies: 4
Views: 30

Re: DOS Batch script - Variable for current system time plus 2 minutes?

Below is a batch script I put together when I was learning how to work with dates and times for a project. It breaks down all of the parts of the date and time and shows how the parts can be put in variables and worked with in various ways. @echo off @setlocal enabledelayedexpansion echo. echo Syst...
by Squashman
21 Jun 2018 00:08
Forum: DOS Batch Forum
Topic: DOS Batch script - Variable for current system time plus 2 minutes?
Replies: 4
Views: 30

Re: DOS Batch script - Variable for current system time plus 2 minutes?

Didn't look to hard at the link you posted but these days I will usually call out to Powershell within my batch file to do any type of date and time math. FOR /F "delims=" %%G IN ('powershell "(Get-Date).AddMinutes(2).ToString('yyyyMMdd hh:mm')"') DO set dtstamp=%%G If you want to get all the indivi...
by Squashman
20 Jun 2018 16:05
Forum: DOS Batch Forum
Topic: which wildcard can be used in this case??
Replies: 13
Views: 84

Re: which wildcard can be used in this case??

for %%f in ("C:\auto_pkg_build\Sources\Source_pkg\%opkg%\%optn%\Factory Download\TETRA\TELIUM3\%VAR14%\Schemes?to?Sign_for_%VAR001%.doc") do ( rename %%f Schemes_to_Sign_for_%VAR001%.doc Does this above command valid? rename %%f Schemes_to_Sign_for_%VAR001%.doc As I alluded to in my previous commen...
by Squashman
20 Jun 2018 15:44
Forum: DOS Batch Forum
Topic: Creatively stupid ways to rename files with spaces to underscores
Replies: 9
Views: 79

Creatively stupid ways to rename files with spaces to underscores

This is really just for shits and giggles . By no means would I ever use this in a production environment. My initial intent was to do this with no set or goto commands. My original flawed logic made me think that renaming any file with spaces to underscores would loop the file back into the `FOR` c...
by Squashman
20 Jun 2018 11:23
Forum: DOS Batch Forum
Topic: which wildcard can be used in this case??
Replies: 13
Views: 84

Re: which wildcard can be used in this case??

goodywp wrote:
20 Jun 2018 09:33
Does this above command valid?
rename %%f Schemes_to_Sign_for_%VAR001%.doc
Well I will give you a hint. What do you need to do with your commands when your file paths or file names contain spaces?
by Squashman
20 Jun 2018 08:54
Forum: DOS Batch Forum
Topic: which wildcard can be used in this case??
Replies: 13
Views: 84

Re: which wildcard can be used in this case??

A question mark for a single character. Here is a good read for you. https://www.dostips.com/forum/viewtopic.php?t=6207 I tried it and not working. probably as sst said that I need to access the file... Thanks anyway.. Really hard to help you when you don't show us the exact code you attempted to u...
by Squashman
20 Jun 2018 07:08
Forum: DOS Batch Forum
Topic: which wildcard can be used in this case??
Replies: 13
Views: 84

Re: which wildcard can be used in this case??

A question mark for a single character.
Here is a good read for you.
viewtopic.php?t=6207
by Squashman
19 Jun 2018 07:34
Forum: DOS Batch Forum
Topic: What's wrong" For loop and pipe | "" problem
Replies: 3
Views: 74

Re: What's wrong" For loop and pipe | "" problem

I see you edited your question to include the closing parentheses but you have not stated whether this fixed your problem.

If it did not fix your problem you need to explain in more detail what the output of your pgp command is and what the expected output of that command should be.
by Squashman
19 Jun 2018 06:39
Forum: DOS Batch Forum
Topic: What's wrong" For loop and pipe | "" problem
Replies: 3
Views: 74

Re: What's wrong" For loop and pipe | "" problem

You are missing the closing parentheses before the DO.