# Writing directory contents to a text file?

**URL:** <https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653>\
**Category:** Factual Questions\
**Created:** [October 6, 2008, 12:41pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653 "2008-10-06T12:41:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![batsto](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@batsto](https://boards.straightdope.com/u/batsto)\
**Post date:** [October 6, 2008, 12:41pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/1 "2008-10-06T12:41:48Z")

</div>

I need to grab the file names from particular directory and have them written to a text file. I know I’ve done this with Perl before, but here at work we don’t have access to the command prompt and my Perl scripts won’t run. Given those limitations, is there another way to do this?

---

<div class="post-metadata">

**Author:** ![Tabby\_Cat](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tabby\_Cat](https://boards.straightdope.com/u/Tabby_Cat)\
**Post date:** [October 6, 2008, 12:45pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/2 "2008-10-06T12:45:47Z")

</div>

How about writing a batch file?

dir \>\> dir.txt

Messy, but gives you something to work with…

---

<div class="post-metadata">

**Author:** ![batsto](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@batsto](https://boards.straightdope.com/u/batsto)\
**Post date:** [October 6, 2008, 12:53pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/3 "2008-10-06T12:53:33Z")

</div>

I can’t get batch files to run–anything that tries to open the command prompt at my office won’t work.

---

<div class="post-metadata">

**Author:** ![Mr.Slant](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Mr.Slant](https://boards.straightdope.com/u/Mr.Slant)\
**Post date:** [October 6, 2008, 12:58pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/4 "2008-10-06T12:58:56Z")

</div>

Uh… that’s a tricky one.  
Only thing I could think of would be pulling up a window, snapshotting, then running an OCR app against the resulting JPEG.  
Can you install cygwin and use that prompt?

---

<div class="post-metadata">

**Author:** ![batsto](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@batsto](https://boards.straightdope.com/u/batsto)\
**Post date:** [October 6, 2008, 1:05pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/5 "2008-10-06T13:05:30Z")

</div>

I’ve never used cygwin before, so I’m not really sure. Probably not—I don’t have admin rights and most stuff won’t let me install it here.

---

<div class="post-metadata">

**Author:** ![Racer1](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@Racer1](https://boards.straightdope.com/u/Racer1)\
**Post date:** [October 6, 2008, 1:09pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/6 "2008-10-06T13:09:32Z")

</div>

The are programs that will do this, but I’m guessing you don’t have the rights to install apps on this machine?

In the unlikely event that you do…

[http://www.download.com/PrintFolders/3000-2248\_4-10067127.html?tag=mncol&cdlPid=10414422](http://www.download.com/PrintFolders/3000-2248_4-10067127.html?tag=mncol&cdlPid=10414422)

---

<div class="post-metadata">

**Author:** ![Tabby\_Cat](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tabby\_Cat](https://boards.straightdope.com/u/Tabby_Cat)\
**Post date:** [October 6, 2008, 1:16pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/7 "2008-10-06T13:16:17Z")

</div>

Hmmm… If you’re familiar with vb script, I suppose you could try using that from within word or excel?

---

<div class="post-metadata">

**Author:** ![Squink](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Squink](https://boards.straightdope.com/u/Squink)\
**Post date:** [October 6, 2008, 1:16pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/8 "2008-10-06T13:16:34Z")

</div>

Display the directory in your browser.  
Save it as a text file.

Drag and drop works for disks/directories in Firefox/Mac.  
Automate it all with Applescript.

---

<div class="post-metadata">

**Author:** ![batsto](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@batsto](https://boards.straightdope.com/u/batsto)\
**Post date:** [October 6, 2008, 1:18pm UTC](https://boards.straightdope.com/t/writing-directory-contents-to-a-text-file/466653/9 "2008-10-06T13:18:00Z")

</div>

I was able to get PrintFolders to run…thanks! You guys just saved me a whole lot of manual work.
