Is it possible to access an NAS drive via CMD and copy all file names from it into a specific file?

12,272

Solution 1

You can tell dir what path to list. So you could use:

dir \\10.51.0.11\nas\Whatever320\PSTs_from_Whatever > C:\dir.txt

Solution 2

Try below steps,

  1. Use "map network drive" to attach the NAS folder path to a drive name eg. z: or X:.
  2. From the cmd try accessing the network path by typing "z:" and hit enter.
  3. Now you can execute any command you want on the NAS folder
Share:
12,272

Related videos on Youtube

Space Ghost
Author by

Space Ghost

Updated on September 18, 2022

Comments

  • Space Ghost
    Space Ghost over 1 year

    There is a way within Windows to access a certain folder and copy all of it's contents names into a text file.

    For example if I am in C:\Users\myusername\Documents

    And in the command line I type dir > C:\dir.txt, when I navigate into the Documents folder, there will be a text file named 'dir.txt', I can now open it and all the names of all the files within my Documents folder will be there (unless thres nothing inside Documents).

    My problem is a bit different.

    I am trying to access an NAS Drive. The path of the file in my example is \\10.51.0.11\nas\Whatever320\PSTs_from_Whatever.

    If I try to navigate here from the command prompt I receive the error:

    CMD does not support UNC paths as current directories.

    I have many, thousands of file names to copy and paste into Excel from this drive and I need a way of doing it other than manually.

    The option of copying and pasting these files is out of the question as it would take many days to make copies from the NAS onto my local network or computer.

  • Space Ghost
    Space Ghost over 8 years
    Thanks for the reply. I don't get the error I used to anymore, however the message I get is 'Access Denied' even when I run CMD as administrator.
  • Ƭᴇcʜιᴇ007
    Ƭᴇcʜιᴇ007 over 8 years
    @SpaceGhost Sounds like you need to ensure you've got proper permission to that folder. Can you navigate to the path via Windows Explorer?
  • Space Ghost
    Space Ghost over 8 years
    @Techie007, Yes, I can.
  • Space Ghost
    Space Ghost over 8 years
    You're correct. I've been an idiot. I can't access it via Windows Explorer. I access this file path via a drive that's shared on our server. The path is a shortcut inside my folder and I navigate to it through that. Thank you for clearing that mistake up. I will attempt something else, if it works, I will post it and accept your answer. :)
  • Ƭᴇcʜιᴇ007
    Ƭᴇcʜιᴇ007 over 8 years
    Ahh, it may be because you're trying to save the dir.txt output file to the root of C:, which is not allowed (that's what's giving you the access denied error). Try just dir \\10.51.0.11\nas\Whatever320\PSTs_from_Whatever on it's own. Does it give you the list? If so, then make a folder and use something like dir \\10.51.0.11\nas\Whatever320\PSTs_from_Whatever > C:\<folder you made>\dir.txt
  • Space Ghost
    Space Ghost over 8 years
    You are a life saver!