Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use command line to pull file names from a network drive

I am wanting to use the command line to output a list of file names to a CSV, but the files are on a network drive.

On my computer I have a folder of movies on my D: drive. By changing the directory in command line and using dir /b > Movies.csvI can obtain a list of all movie titles in that directory. However, we now have a WD NAS box with all of our movies in it and I would like to somehow use command line to pull an updated csv of movie names from it. Since it's no longer on one of my drives in my computer, I am unsure of how to do this.

like image 334
Mason Evans Avatar asked Mar 15 '23 09:03

Mason Evans


1 Answers

Assuming you are talking about windows because you speak of a "D:" drive. You can do the following:

net use X: \\NAS\Share

This will "mount" the \NAS\Share folder to drive "X". Because it is now a drive you can just use regular commands to "cd" to it and then "dir /b > file.csv"

You can also look at https://superuser.com/a/52237/286811 if you do not want a permanent mounted drive.

Even better, I just found out this is also possible

dir /b \\NAS\share
like image 200
Matthijs Avatar answered Mar 17 '23 21:03

Matthijs