topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 8:36 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA Text file of Folder contents  (Read 7628 times)

igors

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 7
    • View Profile
    • Read more about this member.
    • Donate to Member
IDEA Text file of Folder contents
« on: January 17, 2007, 01:10 PM »
I know there are command lines that do just this but I'm not good at remembering where the slashes and backslashes go...
I want, with a simple click on (or drag of) an icon to generate a text file with the names of the files in a given folder.
Naturally it would be nice with settings so all the files in underlying folders would be included, or just the folder names, or ignore files with certain endings, or don't write the endings to the file...
I'm sure there are lots of tweaks that could be applied and that someone would find useful sometime or other.
/GS

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #1 on: January 17, 2007, 01:23 PM »
Well... The basic solution for this is an alternative explorer like xyplorer.
In a very recent thread, there were some alternatives presented. I'll try to find the thread.
Here's the thread.
Apparently, the best option is the one mentioned in this post
« Last Edit: January 17, 2007, 01:25 PM by jgpaiva »

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #2 on: January 17, 2007, 04:58 PM »
igors,

What a great opportunity to begin your exciting adventure into the world of programming!!! This would be a great first project. Create a simple batch file, called DIR2TXT.BAT that takes one argument, the directory you wish to send to the file. Then maybe expand upon it to take a second argument that is the name of the file you want the names to go into.

I'm sure many of us here would help you through it.

Hints
  • Take a look at the /B option for the DIR command.
  • Research "redirecting" stdout to a file.
  • Look for help on the Web, like this.


JohnTurnbull

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #3 on: January 18, 2007, 07:12 AM »
There's a multi clipboard called "Spartan"  ( http://m8software.com )

With that running, click "Select all" then "Copy" in explorer and Spartan creates a text clip with all the selected files or sub folders, one per line. You can then paste it into Notepad (or anything else) to save.

...

chedabob

  • Participant
  • Joined in 2006
  • *
  • Posts: 34
  • C# Master (if only!!!)
    • View Profile
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #4 on: January 18, 2007, 03:37 PM »
I could try this. Luckily I have my C# Textbook with me XD

Edit: Actually, earliest I could get it done is Monday. I left my usb thumb drive in a computer at college, then the building got evacuated (the roof blew off), and I can't get my stuff back till monday. It just so happens that the only copy of the source code for my program that handles text files, is on that drive, and the code is also in my bag (also at college  :()
« Last Edit: January 18, 2007, 04:04 PM by chedabob »

chedabob

  • Participant
  • Joined in 2006
  • *
  • Posts: 34
  • C# Master (if only!!!)
    • View Profile
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #5 on: January 20, 2007, 12:35 PM »
Right, its practically finished. It just needs drag N drop adding (which is a being a pain in the arse) and sorting out a small bug with file creation. At the moment, you enter the directory in one text box*, and the output file in the bottom, then you click "Lets Go!", but the main problem is if the output file does not exists, it is created, but the program holds it in memory, so when I come to write it, it can't, because its already in use. If anybody can shed some light on this, id be ever so grateful.

* I hope to change this so that it is just a small icon that remains onscreen, and when you drop a folder on it, it does its thing, and creates a file called output.txt in the same folder.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA Text file of Folder contents
« Reply #6 on: January 20, 2007, 08:56 PM »
 :) Here's a combined command line and drag and drop tool.

Drag a dir on it to have it create a Files.txt of the filenames of the dropped dir in the dropped dir.
Or run it like a regular command line tool with paramaters.

To compile it to an exe, download AutoHotkey.

Skrommel


;Dir2Txt.ahk
;  Text file of folder contents
;  Syntax: Dir2Text "<sourcefiles>" "<targetfile>" <includefolders?> <recurse?> <fullpath?> <append?> "<ignore>"
;  Example:      Dir2Txt.ahk "c:\test\*.*" "c:\test.txt" 0 0 0 0 "exe,com,bat"
;    Read filenames in c:\test\ into c:\test.txt ignoring exe, com and bat files
;  Example:      Dir2Txt.ahk "c:\test\*.*" "c:\test.txt" 1 1 1 1 "exe,com,bat"
;    Read full path of all files in the directory tree c:\test\ into c:\test.txt ignoring exe, com and bat files
;Skrommel @2007


If 0>1
{
  sourcefiles=%1%
  targetfile=%2%
  recurse=%3%
  includefolders=%4%
  fullpath=%5%
  append=%6%
  ignore=%7%
}
Else
{
  sourcefiles=%1%\*.*
  SplitPath,sourcefiles,name,dir,ext,name_no_ext,drive
  targetfile=%dir%\Files.txt
  recurse=0
  includefolders=0
  fullpath=0
  append=0
  ignore=
}

If append<>1
  FileDelete,%targetfile%
files=
Loop,%sourcefiles%,%includfolders%,%recurse%
{
  If A_LoopFileExt Not In %ignore%
  If fullpath<>1
    files=%files%%A_LoopFileName%`n
  Else
    files=%files%%A_LoopFileLongPath%`n
}
FileAppend,%files%,%targetfile%
« Last Edit: January 20, 2007, 09:05 PM by skrommel »