Jump to content

unix shell script to DOS translation


Recommended Posts

  • 3 months later...
  • 1 month later...

I don't know Unix shell scripting at all, but I'm taking a rough guess and hoping that that's supposed to count the number of files in the root directory.  If not, let me know and I'll revise my batch file for you.  If I'm right in my assumption, here's your Windows batch file equivalent:

 

dir /a "C:\" |find /c /v ""

 

Now, that will only count the number of files in the root directory.  It won't look inside any subdirectories.  Add the /s switch after the /a to search inside subdirectories.

 

If you were trying to make a batch file that asks the user were to search, you could use something like:

 

::File count
::captbeagle
CLS
@ECHO OFF
title Counting your files... one by one!
SET /P directory=Directory to search:
SET /P sub=Search subdirectories [Y/N]:
IF "sub"=="Y" GOTO subs
GOTO no_subs

:subs
dir /a /s %directory% |find /c /v ""
pause
exit

:no_subs
dir /a %directory% |find /c /v ""
pause
exit

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.