Export File List As CSV?

English support forum

Moderators: Hacker, petermad, Stefan2, white

MrMcGoo
Junior Member
Junior Member
Posts: 32
Joined: 2006-08-29, 01:44 UTC

Export File List As CSV?

Post by *MrMcGoo »

How can I export a file list with file details (similar to the list that can be printed) as a csv file?
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

E.g. by utilizing a script, which is feed by TCs parameter "%L"

TC Help >> Dialog box: Configuration - Change button bar
>> Parameters:
>>> %L Long file names including the complete path, e.g. c:\Program Files\Long name.exe


---

A script can be build with AHK, VBS, JS, PoSh, MVVs tool,....


Next utilize the scripting language features
- to parse that TC temp file-list line-by-line
- and to gather the file properties for each file
Build a output string with wanted properties, separated by wanted delimiter.



Non-working Example VBScript:

Code: Select all

sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due the "%L"
   If  FSO.FileExists(sTCtempList) Then
      Set oTextStream = FSO.OpenTextFile(sTCtempList,FORREADING)
      Do Until oTextStream.AtEndOfStream
          vFullName = oTextStream.ReadLine
          Set oFile = FSO.GetFile(vFullName)
          vFile     = FSO.GetFileName(oFile)
          vBase     = FSO.GetBaseName(oFile)
          vExte     = FSO.GetExtensionName(oFile)
          vSize     = oFile.Size
          vVers     = FSO.GetFileVersion(oFile)
          vCreated  = oFile.DateCreated
        '----------------------------------------------------------- 
        'TEST OUTPUT:
          ret = MsgBox("File: " & vbCRLF & vFullName & vbCRLF _
                    & "File: "     & vbTab & vFile         & vbCRLF _
                    & "Base: "     & vbTab & vBase         & vbCRLF _
                    & "Ext: "      & vbTab & vExte         & vbCRLF _
                    & "Size: "     & vbTab & vSize         & vbCRLF _
                    & "created: "  & vbTab & vCreated      & vbCRLF _
                    , vbOKCancel,"TC VBS Test")
          if (ret=vbCancel) Then WScript.Quit
          '-----------------------------------------------------------      
          'TEST OUTPUT 2, CSV-Out:
          vOUT = vOUT & vBase & ";" & vExte & ";" & vCreated
          '-----------------------------------------------------------      
      Loop
      oTextStream.Close
   Else
      WScript.Echo "Input file  sTCtempList  not found."
   End If
' Export vOUT to text file.....


There can be found already many script in the forum, e.g. there are some named like "ForEachSelFileDo".... :wink:



If you tell which properties in which order you want,
and how and where you want to use such script,
there are for sure some scripters here to help you.


At the end you can create a TC button or user command (to assign an hotkey) to launch that script every time you want in the future.




 
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

It's not strictly CSV but you can try cm_SaveDetailsToFile
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Export view list as CSV tab comma semicolon to file

Post by *Stefan2 »

Lefteous wrote:It's not strictly CSV but you can try cm_SaveDetailsToFile
:shock:

That cm_SaveDetailsToFile I had need some times before.

That get me a TAB separated list of the current view. So it is a CSV file.
And with another tool we can exchange all TABs by wanted delimiter as comma or semicolon.


Thanks for sharing. :wink:
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Export view list as CSV tab comma semicolon to file

Post by *gdpr deleted 6 »

Stefan2 wrote:
Lefteous wrote:It's not strictly CSV but you can try cm_SaveDetailsToFile
:shock:

That cm_SaveDetailsToFile I had need some times before.

That get me a TAB separated list of the current view. So it is a CSV file.
And with another tool we can exchange all TABs by wanted delimiter as comma or semicolon.


Thanks for sharing. :wink:
Be careful what tool you choose for tab replacement. Commas and semicolons could be part of a file or directory name. Thus, blindly replacing the tabs without properly quoting or escaping fields containing the chosen new delimiter character can break your CSV file.
MrMcGoo
Junior Member
Junior Member
Posts: 32
Joined: 2006-08-29, 01:44 UTC

Post by *MrMcGoo »

Thank you all for the fantastic responses! I'll digest this all a little and see if I can work with it. My scripting skills are probably beyond the novice level I think but far from expert, so I'll have to spend a little time studying up here. I have used some of the general purpose scripting packages mentioned for small automation projects but don't have extensive experience. It's nice to have something that might advance my skills a bit.

But even nicer to have experts here to consult!

The cm_SaveDetailsToFile idea is a good one. And I think even the TAB delimiters would be OK. But I need something that will also export subfolders and maybe a few other frills. So I'm not sure it's the right solution for this situation. I will take a look at it though just for general knowledge.

Thanks again all... awesome responses! :D
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

MrMcGoo wrote: cm_SaveDetailsToFile

But I need something that will also export subfolders

Try menu "Left > Branch View"


in conjunction with a Custom-Column like

[=tc.path][=tc.fullname]
[=tc.size.bytes]
[=tc.creationdate]
[=tc.attributes]


Next Ctrl+A to select all, following by a cm_SaveDetailsToFile.



Unfortunately we can't remove Name and Ext. from that Custom-Column.
So we had to remove everything from each line till first TAB in that export afterwards.


So all in all, utilizing a script may be more easier / handier.


 
MrMcGoo
Junior Member
Junior Member
Posts: 32
Joined: 2006-08-29, 01:44 UTC

Post by *MrMcGoo »

Hmmmmm...

Looks like you can get a tab delimited list including details by selecting the desired files in the Search result pane, then using the "Mark>Copy .... to Clipboard" command.

You could then paste that into a text file and end up with something that may be a decent workaround even though not a nice direct export.

I've never seen nor used those Mark commands before, but it looks like it should work. And it also gives you several options about what to include although the choices are limited. You can't, for example, have a separate field for the file extension which is something I could use. But I'll give that a whirl and see what happens. It's not perfect, but may be good enough for now.

Any comments on this? Thanks again.
User avatar
nsp
Power Member
Power Member
Posts: 1936
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

If you do not need unicode, you can use TCBL to build your csv file from selected files.
see Total Commander thread for more info.

If you do not want to use echo to build your csv file, you can use the ini file to define a command without any exec and keeping file or use notepad/edit to see the result and save it where you want.
Axxy
Junior Member
Junior Member
Posts: 17
Joined: 2004-09-14, 15:57 UTC
Location: UK

Post by *Axxy »

MrMcGoo wrote:Hmmmmm...

Looks like you can get a tab delimited list including details by selecting the desired files in the Search result pane, then using the "Mark>Copy .... to Clipboard" command.

You could then paste that into a text file and end up with something that may be a decent workaround even though not a nice direct export.

I've never seen nor used those Mark commands before, but it looks like it should work. And it also gives you several options about what to include although the choices are limited. You can't, for example, have a separate field for the file extension which is something I could use. But I'll give that a whirl and see what happens. It's not perfect, but may be good enough for now.

Any comments on this? Thanks again.
I use Custom Columns and "Copy To Clipboard With All Details" all the time. Paste the data into Notepad/Notepad+ and save as standard text. I can then import into Excel quite easy, as if it's csv and edit/export from Excel at will.

I do use 3 Find statements in Excel to strip out the data I need, ie. the file extension before I format the data into what I need. eg. =MID(A1,FIND(".",A1,1)+1,LEN(A1))

It's not an ideal or elegant solution even for me, but I can get filename and meta details into a format quite quickly for my needs.
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2MrMcGoo
2Axxy
You can use cm_SaveDetailsToFile also based on a save result.
Axxy
Junior Member
Junior Member
Posts: 17
Joined: 2004-09-14, 15:57 UTC
Location: UK

Post by *Axxy »

Lefteous wrote:2MrMcGoo
2Axxy
You can use cm_SaveDetailsToFile also based on a save result.
Can it save accented letters properly using this method?
MrMcGoo
Junior Member
Junior Member
Posts: 32
Joined: 2006-08-29, 01:44 UTC

Post by *MrMcGoo »

Lefteous wrote: You can use cm_SaveDetailsToFile also based on a save result.
Indeed! This works.

If you select files in the normal file pane, cm_SaveDetailsToFile returns a tab delimited file with the file names and whatever custom details are in the view.

If you select files in the Search result pane, it returns the same thing, but instead of just a file name, it returns the full path including file name. Not everyone may want the path included in the same field as the file name*, but for my current need this is perfect!

*If you are importing to Excel, you can, of course, write something on the Excel side to parse this field. The test files I created opened perfectly in Excel.

So Lefteous, this is an excellent solution. Thank you!

I also note that every other comment made here was also useful and thank everyone. I can't believe how smart you people are! :shock:

2Axxy
I tested this with the ö character and it worked. :D
Axxy
Junior Member
Junior Member
Posts: 17
Joined: 2004-09-14, 15:57 UTC
Location: UK

Post by *Axxy »

2Axxy
I tested this with the ö character and it worked.
All i get is a small black graphic where the letter should be.
MrMcGoo
Junior Member
Junior Member
Posts: 32
Joined: 2006-08-29, 01:44 UTC

Post by *MrMcGoo »

Axxy wrote:
2Axxy
I tested this with the ö character and it worked.
All i get is a small black graphic where the letter should be.
Hmmmm... may have to do with settings outside of TC? For me it works on Win 7/64
Post Reply