A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label directories. Show all posts
Showing posts with label directories. Show all posts

Windows: folder or file open in another program

When you try to move a folder:

    "The action can't be completed because the folder or a file in it is open in another program"

This stunningly unhelpful error message has persisted through many versions of Windows.

The way I work around it is:

  • Rename an unrelated file or folder nearby, then rename it back again.
  • The original folder or file should now be "unlocked"
You can always reboot to fix it, too.

How to sync over FTP

Don't re-invent the wheel.

1) Install rsync instead, which is designed with syncing in mind.

2) ftpsync was written a decade ago. Perhaps it has been updated since.

3) lftp syncs over FTP and is being actively maintained.

4) Perl package turbo-ftp-sync may also fit the bill.

Moving a wordpress e-commerce site

  • UPDATE wp_options SET option_value="http://newsite/new_dir" WHERE option_value="http://oldsite/old_dir"; -- this fixes most of the site
  • UPDATE wp_options SET option_value="http://newsite/new_dir" WHERE option_value="http://oldsite/old_dir"; -- this fixes the pagination for the e-commerce plugin.
  • In .htaccess:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f [NC]
    RewriteCond %{REQUEST_FILENAME} !-d [NC,OR]
    RewriteCond %{REQUEST_URI} / [NC]
    RewriteRule ^(.*)$ /new/$1 [L,QSA]

Move directory on FTP server

without downloading and re-uploading:

rnfr source_dir
rnto target_dir

Developing over FTP

Using Eclipse and RSE plugin:
  • Logs in okay
  • But seems to always be closing directory sub-trees I've opened in 'Remote Systems' panel
  • It wants to do an 'ls' on every parent directory in the hierarchy, every time I change files. Very slow.
Using CurlFtpFS:
  • Install in Ubuntu from the software centre
    • to mount: curlftpfs -v username:password@server.example.com local_dir/
    • to unmount: fusermount -u local_dir/
  • Performance is unusably slow... Eclipse wants to know about every single file on the remote server, not just the ones I'm editing.
  • Saving the file through Eclipse using CurlFtpFS takes even longer than it would to upload it separately.
Using FileZilla and gedit:
  • Browsing is fast
  • Editing is fast
  • But you have to navigate to every file manually each session, it doesn't remember what you had open
  • The system of holding temp files locally is not ideal, but FileZilla detects changes in them very nicely
  • You still can't grep over the files as they're all held remotely, and it's a bit fiddly to navigate to a specific file
    Editing locally with Eclipse, and uploading after changes are made:
    • Write an Ant script to upload any modified files?
    • ...to investigate

    Password protect a directory in Apache

    Put a .htaccess file in the directory you want to protect, containing:

    AuthUserFile /full/path/to/your/htpasswd_file
    AuthGroupFile /dev/null
    AuthName "Password Protected Area"
    AuthType Basic



    require valid-user


    Then use an online htpasswd generator to create the htpasswd_file at the location you specified for AuthUserFile above. Make sure this is outside your public webspace.

    How to change the colours of directories and files

    To change the colour of directories from dark blue to light blue (cyan):

        export LS_COLORS=$(echo $LS_COLORS|sed 's/di=01;34/di=01;36/')

    See also

        man dircolors

    and

        dircolors --print-database



    ...for a list of the colours.