Search found 22 matches
- 11 Oct 2012 11:21
- Forum: DOS Batch Forum
- Topic: Batch executable to find replace text?
- Replies: 17
- Views: 12870
Re: Batch executable to find replace text?
Hello. I have a question on the code supplied here. This is exactly what I was looking for (search is your friend ) but I cannot make it work. I created the reference file with the names (in my case one value is a number and the other a name). The file I need to alter is a csv file (no problem chang...
- 11 Jan 2012 07:55
- Forum: DOS Batch Forum
- Topic: Batch Move Files (some syntax queries)
- Replies: 3
- Views: 4860
Re: Batch Move Files (some syntax queries)
How do you do this same thing but for all subfolders as well?
- 15 Aug 2011 07:03
- Forum: DOS Batch Forum
- Topic: Changing value of a specific field based on a diff field
- Replies: 3
- Views: 4156
Re: Changing value of a specific field based on a diff field
All I really wanted was a good point in the right direction, but I certainly won't complain that you wrote something for me that works perfectly. As usual, I'm learning stuff from reading the code you give me, and I appreciate the help and the education. Do you know of a good tutorial for the part o...
- 12 Aug 2011 08:21
- Forum: DOS Batch Forum
- Topic: Changing value of a specific field based on a diff field
- Replies: 3
- Views: 4156
Changing value of a specific field based on a diff field
I am trying to read the 9th, 11th, 13th, 15th and 17th fields in each line and if they are blank, remove the value from the previous field. I have numerous bugs here, the most obvious of which is that I can't figure out how to change the value associated with the token and write it back to the line ...
- 20 Jul 2011 13:37
- Forum: DOS Batch Forum
- Topic: How to verify current directory?
- Replies: 7
- Views: 6667
Re: How to verify current directory?
Nope, no AutoRun.
I give up. I'll just have to test it in the field.
Thank you for all your help. The two variables are a world of help.
I give up. I'll just have to test it in the field.
Thank you for all your help. The two variables are a world of help.
- 20 Jul 2011 06:04
- Forum: DOS Batch Forum
- Topic: How to verify current directory?
- Replies: 7
- Views: 6667
Re: How to verify current directory?
I don't know what is going on with my computer. There must be a setting, or perhaps some domain thing going on, because even though the path shown in the title bar is system32, with or without the quotes, both commands return the desktop. Further, when testing a batch that moves files from the deskt...
- 18 Jul 2011 09:55
- Forum: DOS Batch Forum
- Topic: How to verify current directory?
- Replies: 7
- Views: 6667
Re: How to verify current directory?
I think I know the problem. Those happen if you run the code as administrator. The easies way could be to change the working directory to the path of your batch: @echo off cd /d "%~dp0" :: your stuff here Regards aGerman This indicates that even though Windows is running the batch file fr...
- 15 Jul 2011 11:15
- Forum: DOS Batch Forum
- Topic: How to verify current directory?
- Replies: 7
- Views: 6667
How to verify current directory?
I have a number of batch files that get used regularly by my coworkers, but now that Win7 is everywhere, I have encountered a problem. I want to keep it simple and have them just throw a folder on the desktop temporarily and run the batch from inside it then delete the folder afterwards. The problem...
- 17 Jun 2011 14:15
- Forum: DOS Batch Forum
- Topic: Using If ... Else within a Batch file - FTP Script
- Replies: 5
- Views: 12401
Re: Using If ... Else within a Batch file - FTP Script
I find that If Else in batch files is a pain in the neck. Half the time I cannot get it to work.
I usually end up doing
If test command
If Not sametest newcommand
I usually end up doing
If test command
If Not sametest newcommand
- 17 Jun 2011 13:22
- Forum: DOS Batch Forum
- Topic: Keyboard input of source file in "FOR /f" loop
- Replies: 4
- Views: 7126
Re: Keyboard input of source file in "FOR /f" loop
Acy Forsythe wrote:Code: Select all
@echo off
Set file=source.txt
for /f "usebackq tokens=* delims=" %%a in (%file%) do Echo %%a
You can get the value for %file% anyway you choose like Set /P for instance...
I swear I tried that and it didn't work. This time it does.
Thank you.
- 17 Jun 2011 12:28
- Forum: DOS Batch Forum
- Topic: Keyboard input of source file in "FOR /f" loop
- Replies: 4
- Views: 7126
Keyboard input of source file in "FOR /f" loop
I can input the variable to the batch file okay using set /p, but no matter what I do I get an error that the file cannot be found and the error always shows the variable name that I used to collect the filename. Can someone explain the syntax of this? for /f "usebackq tokens=* delims=" %%...
- 17 Jun 2011 12:16
- Forum: DOS Batch Forum
- Topic: Pad unequal length lines with spaces to make all the same.
- Replies: 3
- Views: 4500
Re: Pad unequal length lines with spaces to make all the sam
The more I think about it, the more I like my second method. It works and it should be clean. Using the second SET not only sets the value that I want, but also sets the length, which is important because the records are of varying length. It's nice to have someone else tell me I'm not totally out i...
- 17 Jun 2011 11:32
- Forum: DOS Batch Forum
- Topic: Pad unequal length lines with spaces to make all the same.
- Replies: 3
- Views: 4500
Pad unequal length lines with spaces to make all the same.
Not having a full grasp of all the commands available, for all I know there might be a command that will do this properly. Bearing in mind that the line being read in is less than 80 characters, what I have done is read in the short line and write it to the output file defined as a longer line, like...
- 17 Jun 2011 10:55
- Forum: DOS Batch Forum
- Topic: Reading a specific character in a line and comparing it.
- Replies: 7
- Views: 6871
Re: Reading a specific character in a line and comparing it.
I got it. I think I even understand most of it, thanks to having a functional example and the wonders of Google to look up what you were doing. I thank you both for the help. I have another question in the same project but it is different enough from this that it should be its own topic, so I'll ope...
- 16 Jun 2011 20:29
- Forum: DOS Batch Forum
- Topic: Reading a specific character in a line and comparing it.
- Replies: 7
- Views: 6871
Re: Reading a specific character in a line and comparing it.
Hi mid_life_crisis, I suppose you want to do something like this... Print only all lines with "A" as first character, but add a "#" to the line. @echo off setlocal DisableDelayedExpansion ( for /f "usebackq tokens=* delims=" %%a in ("infile.txt") do ( set &qu...