Skip to content

Help with DOS command

Featured Replies

I have a DOS command that I can run from the root directory of a drive or network share and it will list the folder name (not file name) that contains any MP4 files, however, it lists to screen and I am trying to get it to list to a text file but the usual >output.txt won't work - any suggestions?

 

Here is the command I am using:

 

for /r %a in (.) do @if exist "%~fa\*.mp4" echo %~fa

  • Author

Cancel that - it needed to be >>output.txt

even better try having a look at Powershell it is DOS on steriods

 

John

I'd be thinking do

 

dir *.mp4 /s > output.csv

 

open the file in excel and just filter the data to show any rows starting "c:\..."

I'd recommend ZTREE to look inside Directories ( old name for FOLDERS).You can also search by file type using the known file type extension ( e.g for applications in a directory, type in ,in the file line *.exe). Alternatively in DOS, you can access a directory ( DIR/W/P, gives a list that stops when page is full, CD ,"DIR" will access a directory of name "dir" and cd// will return to root). Advantage of ZTREE is that you have no file length name restriction( unlike pure DOS /XTREE), and it's a menu driven system. Again there is also XTREE,( older version, which has file name length restrictions), but will work a lot better in old versions of DOS, where ZTREE might not. I've never tried printing from either, so no help there .

Move to linux? :p

 

Colour me impressed if you know how to do that from the shell off the top of your head!

Colour me impressed if you know how to do that from the shell off the top of your head!

Off the top of my head, the following should do it, where $DIR is replaced by the top level directory:

  

find $DIR -type f -iname '*.mp4' -print > foobar.txt
 

Wonder how many errors I have in there.

Edited by cheezemonkhai

Sounds legit enough to impress me.

  • Author

Problem with most of these suggestions is it will give me a list of files - I just want the folder names that those files are in. There could be thousands of files but only dozens of directories

back to powershell

 

$type = "*.mp4"   this is the type of file you are looking for

dir c:\$type -Recurse | Select Directory -Unique | sort Directory | Export-Csv c:\data\info.txt

 

this will check for all mp4 files on the C drive and put the directories they are in into a file called info.txt in a directory called data on C drive

 

John

Martin - find one file you know of in a directory- it will have a file  extension-as I mentioned applications have file extensions of .exe. Batch files are .bat . Then on ZTREE , use the F tag to ask Ztrtee to look for look for files of the type you  want. OR , YOU CAN do it in DOS- but it's more demanding- as you  have to search through each directory using the tag dir*."file" .I'd use Z TREE - IT wil search dozens of directories.

Problem with most of these suggestions is it will give me a list of files - I just want the folder names that those files are in. There could be thousands of files but only dozens of directories

quote name="jjc" post="4661295" timestamp="1467729599"]

back to powershell

 

$type = "*.mp4"   this is the type of file you are looking for

dir c:\$type -Recurse | Select Directory -Unique | sort Directory | Export-Csv c:\data\info.txt

 

this will check for all mp4 files on the C drive and put the directories they are in into a file called info.txt in a directory called data on C drive

 

John

Proof be it windows or Linux, that a proper shell is always the answer :)

back to powershell

 

$type = "*.mp4"   this is the type of file you are looking for

dir c:\$type -Recurse | Select Directory -Unique | sort Directory | Export-Csv c:\data\info.txt

 

this will check for all mp4 files on the C drive and put the directories they are in into a file called info.txt in a directory called data on C drive

 

John

 

Thats the best soloution i've seen in this thread so far.

Similarly in DOS ,TYPE IN DIR *.MP4 (I THINK FROM MEMORY)

 

Simpler in ZTREE- open ztree ,which will show folders in root.

using the instructions, you will find that one use of the F key will select files and ask for filename -- enter MP4, press enter and a list of all files *.mp4 will be returned.  will be returned.

using other keys you can select drive, although i don't know if you can do it in true dos.

 

HOWEVER- unless PC is opened in DOS, you will need to download the correct version ( 32/64 bit), which will run under Windows in DOS mode.

 

I do assume that drive(s) you wish to access are formatted in dos ( if not- forget line 1), but however, there is a bootable CD available on line which wil boot up a PC from NTFS and let you look at root etc.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Important Information

Welcome to BRISKODA. Please note the following important links Terms of Use. We have a comprehensive Privacy Policy. 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.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.