Please register or login. There are 0 registered and 1185 anonymous users currently online. Current bandwidth usage: 326.30 kbit/s December 13 - 02:19am EST 
Hardware Analysis
      
Forums Product Prices
  Contents 
 
 

  Latest Topics 
 

More >>
 

    
 
 

  You Are Here: 
 
/ Forums / General Technology /
 

  MSDOS Switch to suppress path 
 
 Author 
 Date Written 
 Tools 
binar Jan 24, 2014, 09:47pm EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List Replies: 7 - Views: 2342
Fellow Forum Members,

Using the MSDOS command below:

C:\Root>dir /b /s | more

Produces the list below on my monitor screen:
C:\Root>file1.doc
C:\Root>file2.doc
C:\Root>file3.doc
C:\Root>file4.doc

The problem is I don't want the "C:\Root" text to appear. I only want the "file#.doc" text to appear on my monitor screen. What switch do I need to use (besides /b & /s) to prevent the "C:\Root" text from appearing. In short, my goal is to only generate a list that creates a filename list without any path information included. Any info will be appreciated.




Want to enjoy fewer advertisements and more features? Click here to become a Hardware Analysis registered user.
john albrich Jan 24, 2014, 10:08pm EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List

Edited: Jan 24, 2014, 10:34pm EST

 
>> Re: MSDOS Switch to suppress path
.
You might look into using XXCOPY instead of limiting yourself to just MSDOS batch commands. It's been awhile since I last used it but it was very powerful and flexible. If I'm remembering things correctly, I used it to do something very similar.
WARNING
Because XXCOPY is so powerful, especially with the multiple wildcard capabilities, a single USER mistake can devastate/delete many files. I speak from experience. My suggestion is to always have a full backup of one's entire system (which I do as routine anyway). I'd even go so far as to recommend using a dedicated test system when first becoming acquainted with and writing XXCOPY scripts.

Online XXCOPY User Manual: http://www.xxcopy.com/xcpytbul.htm

http://www.majorgeeks.com/files/details/xxcopy.html
http://www.xxcopy.com/
XXCOPY 3.21.0
Author: Pixelab, Inc.
Date: 08/06/2013 04:43 PM
Size: 2.97 MB
License: Freeware
Requires: Win 8 / Win 7 / Vista/ XP
Downloads: 8121 times
Rating: 4 (14 votes)

XXCOPY is:
# A versatile file management tool for Microsoft Windows®.
# It is a command-line program (without graphical user interface).
# Supports all Windows versions (except Windows CE).
# It has more command switches (>230) than any other tool of its kind.
# An ideal component for batch files for simple and complex scripting.
# Accesses remote (networked) computer storage and local external USB drives.
# Command syntax compatible with Microsoft's XCOPY with few exceptions.
# Competes with (supersedes) Microsoft's RoboCopy.
# One download package contains both the 32-bit and 64-bit XXCOPY versions.
# Extremely rich in file-selection mechanism (by filedate, size, attrib, etc.).
# Wild-Wildcard (specify a path with wildcard anywhere for any number of times).
# Functions for Copy, List, Gather, Delete, Move, Flatten-Dir, and more ...
# A very mature product (the first XXCOPY version was published in 1999).


edit:
20140124 to add: as with any batch/script approach, be careful when including recursive algorithms...one can obtain unanticipated results with what might seem to be an inconsequential change in the script. It's always a good idea to test the script and small, manageable set of input data and compare the actual output against expected output as determined via alternate means (including manual iteration). One should also consider testing the results any/every time one edits the script.
20140124 to add: hyperlink to on-line user manual and to add a personal WARNING.

john albrich Jan 25, 2014, 12:45am EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Non-batch/Non-CommandLine GUI-based Possible Alternatives
.
I know you spec'd a Command Line implementation, but just in case...if you can use, or don't mind using Windows GUI programs, here are some possible alternatives that may provide the equivalent functionality as well. At the very least, XYplorer has made my day-to-day life much easier. *


XYplorer
XYplorerFree 13.70.0100, released 24-Jan-2014
http://www.xyplorer.com/index.php
http://www.xyplorer.com/features.php
http://www.xyplorer.com/free.php (free version download)
XYplorer is a tabbed file manager for Windows. It features a powerful file search, a versatile preview, a highly customizable interface, optional dual pane, and a large array of unique ways to efficiently automate frequently recurring tasks. It's fast and light, it's innovative, and it's portable.


I don't know for sure that the following programs will still do what you're looking for, but they may do so. I'm pretty sure they used to do so.

Q-Dir
http://www.majorgeeks.com/files/details/q_dir_portable.html
http://www.softwareok.com/
Q-Dir Portable 5.92
Author: Nenad Hrg
Date: 01/22/2014 09:12 AM

xplorer2-lite
http://zabkat.com/x2lite.htm
http://zabkat.com/comparison.htm (comparison table of xplorer2 versions v. Windows Explorer)


* I've used XYplorer Free edition as an alternative to Windows Explorer for years. It's very powerful and flexible. In my opinion it's far superior to Windows Explorer. However, I've not had to update in a looong time (I'm still using v5.55). I know that XYplorer Free can provide the end-result you're looking for. In fact, you can even custom select which of the file path/name/status components for output (e.g. path, filename, extension, modified date, and so on) thus removing all the rest of the clutter as desired from your search columnar output. I do that all the time time. But, the function can't be included in a batch file unless you use a keyboard/mouse macro script generator like AutoHotKey http://www.majorgeeks.com/files/details/autohotkey.html

Dr. Peaceful Jan 25, 2014, 05:25am EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Re: MSDOS Switch to suppress path
binar said:
Fellow Forum Members,
Using the MSDOS command below:

C:\Root>dir /b /s | more

Produces the list below on my monitor screen:
C:\Root>file1.doc
C:\Root>file2.doc
C:\Root>file3.doc
C:\Root>file4.doc

The problem is I don't want the "C:\Root" text to appear. I only want the "file#.doc" text to appear on my monitor screen. What switch do I need to use (besides /b & /s) to prevent the "C:\Root" text from appearing. In short, my goal is to only generate a list that creates a filename list without any path information included. Any info will be appreciated.

The /b option supposed to show bare format. If you use that alone, it will show just the filenames within the directory. However, use it along with /s (recursive), it's showing the directory path together with filenames, because you could have files with same names under different directories.

It may be possible to do it in DOS to strip the path, but it wouldn't be a one liner. You probably need to write a .bat file with some kind of loop. Time to use Powershell, it's the way to go for the future of Windows.

Here's the powershell command to do what you intended.
get-childitem -recurse | select-object name


john albrich Jan 25, 2014, 07:55am EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Re: MSDOS Switch to suppress path
Dr. Peaceful said:
Here's the powershell command to do what you intended.
get-childitem -recurse | select-object name


Any command that contains within it the explicit parameter "recurse", does not bode well. I suspect such can only "spawn" bad things :P

And to curse a child's beloved toy in what is clearly a Satanic rite (by invoking the object that must not be named)...well, that's just unspeakable...which is of course why I typed it.

binar Jan 25, 2014, 09:15pm EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Re: MSDOS Switch to suppress path
John and Dr. Peaceful,
Thanks to both of you for your posts. John I tried out Q-Dir since it's freeware and it has an EXPORT menu selection that accomplishes the same thing I'm trying to do using MSDOS. All it requires is to select files you want as text and then export selection as MicroSoft Excel. In short, it's a great little app. Again thanks for your post.

Dr. Peaceful Feb 02, 2014, 11:19pm EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Re: MSDOS Switch to suppress path
LOL John. ;) Hey don't blame me, blame Micro Sauce for their peculiar command names, as they're trying to sound Object Oriented.

Binar, you're welcome. Glad you find a solution.

Gerritt Feb 24, 2014, 09:20pm EST Reply - Quote - Report Abuse
Private Message - Add to Buddy List  
>> Re: MSDOS Switch to suppress path
It has been bloody forever sense I've scripted in MSDOS batching language, but I seem to remember there was an "exclude" option on the piped redirects to file or console or other output. You could exclude certain portions of output based upon the path or anything else.

Ad Astra Per Aspera
(A rough road leads to the Stars)
We all know what we know, and everyone else knows we are wrong.
System Specifications in BIO

Write a Reply >>


 

    
 
 

  Topic Tools 
 
RSS UpdatesRSS Updates
 

  Related Articles 
 
 

  Newsletter 
 
A weekly newsletter featuring an editorial and a roundup of the latest articles, news and other interesting topics.

Please enter your email address below and click Subscribe.