Showing posts with label dos. Show all posts
Showing posts with label dos. Show all posts

Command Prompt/DOS: How to batch rename files

Surprisingly, the RENAME (aka REN) command in DOS supports wildcards.

If you had a stack of files called:

  • DSC_0001.JPG
  • DSC_0002.JPG
  • DSC_0003.JPG
  • DSC_0004.JPG

You could call:

REN DSC_*.JPG Photo_*.jpg

And it'll replace the text accordingly like:

  • Photo_0001.jpg
  • Photo_0002.jpg
  • Photo_0003.jpg
  • Photo_0004.jpg

What's even more surprising is that this solution came from Yahoo answers!

b2DSD
Hit me outta nowhere!

Source

Windows: Find and delete files of a given pattern (also searching subdirectories)

I needed a quick way to clear out all the compiled Python ".pyc" and Java ".class" files on my drive, and searching via Windows Explorer is just slow.

  • Open up a command prompt.
  • Go to the folder to start from.
  • Type in:

del /S *.pyc

del /S *.class

It'll all be over after the wall of text has finished moving.

8QmIp 
So simple, so effective.

Source

Command Prompt: Pause with "Press any key to continue"

In a batch file, add pause to display the "Press any key to continue . . ." message.

@echo off
php generate.php
pause

Optionally you can use "@echo off" to hide the commands being sent, so the script wont display stuff like "php generate.php" and "pause".

Can't change directory to another drive in DOS Command Prompt

I'm not sure when Microsoft decided to change this syntax, but I am quite certain back in the old days of DOS I was able to type this "cd D:\games\mmx" and it'd work!

Sometime last year I noticed that I could no longer do this on the XP command prompt window. Its been nerfed. Why? I do not know.

At first I thought it was because I was using it via a remote desktop session and thought nothing of it (apart from being annoying).

Just today, I realised it also affected my local sessions also. So off I went to discover a way to fix it.

Typing in "cd /?", I found this.
CD [/D] [drive:][path]
Type CD drive: to display the current directory in the specified drive.

Use the /D switch to change current drive in addition to changing current directory for a drive.
I tried it and it worked.
What the hell?
C:\Documents and Settings\twig>cd d:
D:\

C:\Documents and Settings\twig>cd /d d:

D:\>
So I guess now we have to use the new syntax to change drives using "cd".
How annoying.
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog