Get file list from cPanel or Filezilla

Discussion in 'IT & Internet' started by Jeff FV, Apr 17, 2012.

Thread Status:
Not open for further replies.
  1. Jeff FV

    Jeff FV UKBF Big Shot Staff Member

    3,720 1,772
    I'd like a list of files that are on my website, ideally in a csv format, is there any awy of doing this using either cPanel or Filezilla. Apparently the dirInfo button on Filezilla gives a copy and pastable text window, but I can't seem to find the dir Info button!

    To be a little more specific, I have one folder that contains .jpg images, I'd like a list of those images.

    I'm sure there must be a way to do this - can anyone help?

    Thanks in advance

    Jeff
     
    Posted: Apr 17, 2012 By: Jeff FV Member since: Jan 10, 2009
    #1
  2. Dan_HiHosting

    Dan_HiHosting UKBF Ace Full Member

    1,106 271
    I think DirInfo was a feature request that wasn't actually implemented.

    You can go to Edit > Settings > Debug (last item) > And select "show raw directory listing"

    Close FileZilla. Open it again. Then when you connect, the message window (the top one), will list all your files.

    It's pretty verbose, with one file per line, e.g:

    Listing: type=file;size=926;modify=20110113220630;UNIX.mode=0644;UNIX.uid=594;UNIX.gid=591;unique=803g31f10a2; test.php

    You can then copy and paste that to a program of your choice.
    To store it as a csv using that output you'd probably want to save it all as a text file in Linux and then use grep, awk etc, to remove certain text and insert the commas in the right place!

    I hope that helps!

    EDIT: Actually, if you just do a edit > replace in notepad, and replace all the ; with , and save the file as a .csv it'll then open properly in Excel etc. Any columns/attributes you don't want you can then easily delete.
     
    Last edited: Apr 17, 2012
    Posted: Apr 17, 2012 By: Dan_HiHosting Member since: Mar 7, 2011
    #2
  3. Posilan

    Posilan UKBF Ace Full Member - Verified Business

    2,546 878
    Hi Jeff,

    Upload this PHP script to the web directory you want to get the listing for and view it in your web browser - should just be a cut n paste job then :)

    Code:
    <?php
     if ($handle = opendir('.')) {
       while (false !== ($file = readdir($handle)))
          {
              if ($file != "." && $file != ".." && (strlen(strstr($file,'.jpg'))>0))
              {
                    $list .= $file.'<br />';
              }
           }
      closedir($handle);
      }
    ?>
    <P><?=$list?></p>
    Steve
     
    Posted: Apr 17, 2012 By: Posilan Member since: Dec 20, 2010
    #3
  4. Jeff FV

    Jeff FV UKBF Big Shot Staff Member

    3,720 1,772
    Brilliant!

    Thanks to you both.

    Steve - I've uploaded your snippet of code and its done what I needed.

    Dan - I may give your method a try later on.

    Thanks again!

    Jeff
     
    Posted: Apr 17, 2012 By: Jeff FV Member since: Jan 10, 2009
    #4
Thread Status:
Not open for further replies.