Monday, June 1, 2015

Finding Largest Files in Bash

I often need to find the largest files in a directory tree.

I have used

du -a | sort -nr | head -n 10

but it includes directories.

To exclude all directories, I tried using find.

find -type f -exec ls -l {} \; | tr -s ' ' | cut -d' ' -f 5,9- | sort -rn | head -n 10

Explanation
  1. -type f means only look at files
  2. -exec ls -l {} \; means to show a long listing for each matched file
  3. tr -s ' ' replaces multiple occurrences of space with one space
  4. cut -d' ' -f 5,9- sets the delimiter to space and displays the columns 5 and everything after 8. Column 5 is the size, everything after 8 is the file name (with possible embedded spaces)

Saturday, March 7, 2015

Moving Dropbox From The Roaming Profile

When roaming profiles get big, they take a long time to load.

Dropbox stores its configuration files in the roaming profile. Some of the files are large.

After installing Dropbox, I noticed that the data files were stored on a network drive and the config files were in my roaming profile. I did not like either of these locations, but Dropbox installation does not allow them to be changed.

After installation, I was able to open the advanced Dropbox preferences and move the data file to a local drive. I tried several tricks to get Dropbox to move the config files to the local drive, but nothing worked.

I thought about symbolic links in Linux. I am using Windows 7, which has a mklink command.

I stopped Dropbox, moved the config folder to the local drive and created a link from the AppData\Roaming\Dropbox to the config file on the local drive.

I created a script that tests if the local folder exists and then creates the link. I created an admin task that starts the script on log on.

if not exist c:\local_data goto nolocal
mklink /j c:\Users\xxxxxx\AppData\Roaming\Dropbox c:\local_data\DropboxFromRoaming
:nolocal

Dropbox is now stored on my local drive, not in my roaming profile.

Update: When I logged off, the Dropbox folder was stored to my roaming profile. On the next login, the link could not be created, since the folder existed. It is necessary to ignore Dropbox in the roaming profile:   https://support.microsoft.com/en-us/kb/188692

I had tried the Group Policy, but it was ignored. I modified the registry and was able to leave Dropbox out of my profile.

Conclusion: It is not necessary to mess with links, just use the registry to keep Dropbox out of the roaming profile.



Followers