Search found 391 matches

by avery_larry
12 Apr 2010 09:38
Forum: DOS Batch Forum
Topic: rename filenames 'Extensions' EVEN in SubFolders
Replies: 2
Views: 4297

Re: rename filenames 'Extensions' EVEN in SubFolders

*untested* probably a bit more efficient:

Code: Select all

for /f "delims=" %%f in ('dir /s /b /a-d "c:\old files\*.bmp"') do ren "%%f" "%%~nf.BMP"
by avery_larry
07 Apr 2010 12:23
Forum: DOS Batch Forum
Topic: Close an OPENED folder or programs!!
Replies: 1
Views: 3946

Re: Close an OPENED folder or programs!!

You could try to figure out the "taskkill" command.
by avery_larry
05 Apr 2010 10:05
Forum: DOS Batch Forum
Topic: Setting variables in a for line?
Replies: 1
Views: 4831

Re: Setting variables in a for line?

set list=!list:~-%length%!
echo "$basetexture" "!list!" >> %%~pnA.vmt

or don't bother with the first set:

echo "$basetexture" "!list:~-%length%!" >> %%~pnA.vmt
by avery_larry
05 Apr 2010 09:58
Forum: DOS Batch Forum
Topic: Remove folder once it is empty!!!
Replies: 3
Views: 5248

Re: Remove folder once it is empty!!!

Just try to remove the directory. If it's not empty, it will fail:


rd "c:\dir to be deleted"
by avery_larry
05 Apr 2010 09:57
Forum: DOS Batch Forum
Topic: Automatically Organize Files according to their file types!!
Replies: 1
Views: 3499

Re: Automatically Organize Files according to their file typ

I would do it manually from the command prompt: cd /d c:\mess move *.pdf "c:\document\pdf" move *.doc "c:\document\doc" It would take you just about as long to write the script file as it would be to just do it. Don't forget to make the directory first if needed: md "c:\docu...
by avery_larry
05 Apr 2010 09:54
Forum: DOS Batch Forum
Topic: add in shortcut.exe command as an internal command??
Replies: 1
Views: 3566

Re: add in shortcut.exe command as an internal command??

If you're on a network, you can put it in a common location and reference it with full path all the time f:\public\shortcut.exe If it's in one of the standard directories on every machine you could use "%windir%\system32" or something similar: "%programfiles%\my software\shortcut.exe&...
by avery_larry
05 Apr 2010 09:52
Forum: DOS Batch Forum
Topic: display full path when only certain files are searched
Replies: 3
Views: 5289

Re: display full path when only certain files are searched

If the directory is large, it might be more efficient to build the list of files first using findstr as you have done, but then instead of a dir /s on each match found, just put that list of files into another file and use findstr on a single dir /s. Something like (untested): for /f "delims=&q...
by avery_larry
05 Apr 2010 09:44
Forum: DOS Batch Forum
Topic: add in text string in a text string from a ref.txt
Replies: 1
Views: 3614

Re: add in text string in a text string from a ref.txt

Code: Select all

for /f "usebackq delims=" %%a in ("c:\path to file\ref.txt") do echo %%a
by avery_larry
05 Apr 2010 09:37
Forum: DOS Batch Forum
Topic: set current directory (CD) in a bat from another ref.txt
Replies: 6
Views: 8349

Re: set current directory (CD) in a bat from another ref.txt

Oops. Mixed up tokens and delims:

Code: Select all

for /f "usebackq delims=" %%a in ("c:\path to ref\ref.txt") do cd /d "%%~a"
by avery_larry
05 Apr 2010 09:30
Forum: DOS Batch Forum
Topic: String operations "inside" a FOR command
Replies: 4
Views: 7123

Re: String operations "inside" a FOR command

I actually prefer many times to use the subroutrine trick instead of the call trick or delayedexpansion: @echo off for %%a in (abce efge ieks eiw) do call :process %%a echo Your other code here goto :eof :process set tmp_var=%1 echo %tmp_var:~2,3% goto :eof Effectively, this pulls the "guts&quo...
by avery_larry
31 Mar 2010 11:26
Forum: DOS Batch Forum
Topic: Running batch file with runas command
Replies: 3
Views: 5674

Re: Running batch file with runas command

Better: Will pause pretty much no matter what: RUNAS /U:DESQLD\USERNAME_ADMIN "cmd /c \"REG QUERY \\%PCASSET%\HKEY_LOCAL_MACHINE\SOFTWARE\DES\CustomData /s ^& pause\" " Will pause only if it is successful: RUNAS /U:DESQLD\USERNAME_ADMIN "cmd /c \"REG QUERY \\%PCASSE...
by avery_larry
31 Mar 2010 11:09
Forum: DOS Batch Forum
Topic: Running batch file with runas command
Replies: 3
Views: 5674

Re: Running batch file with runas command

Code: Select all

RUNAS /U:DESQLD\USERNAME_ADMIN "cmd /k \"REG QUERY \\%PCASSET%\HKEY_LOCAL_MACHINE\SOFTWARE\DES\CustomData /s\" "
by avery_larry
31 Mar 2010 11:02
Forum: DOS Batch Forum
Topic: replacing text
Replies: 4
Views: 6372

Re: replacing text

If you're always talking about the batch file that is running, then use "%~n0". That returns the filename without the extension of the batch file that is currently running. Otherwise there are several ways to do that, but I would continue with the above theme by using a call statement: @ec...