Pages

Thursday, August 18, 2011

Mac -=- Removing dot underscore "._" files...

In some cases involving the Apple Double format, moving a file to a different file system will cause the prefix "._" to appear on a file name. The files "._" are invisible when you're trying to list the file even with "ls -al" but you can see them when you compress a file. 

To remove them, you can go on the root of the directory and type
find . -name '._*' -delete

In order to PERMANENTLY resolve this issue, you can however, add one of the following 2 lines of code to your .bash_profile file in your home directory:
# for Tiger OS 10.4 or earlier
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

# for Leopard OS 10.5 and later
export COPYFILE_DISABLE=true

Tuesday, August 16, 2011

Linux -=- Find files and copy to a folder

Hi!

Here's how to copy the files found in the result of a search to a specified folder.

find /path/to -iname 'whatever' -exec cp '{}' /path/to/destination/ \;

Tuesday, August 9, 2011

Java -=- Regex find example

Here's a simple example that shows how to find the value of different groups in a string with a regular expression.

Pattern pattern = Pattern.compile("^([a-zA-Z0-9]*)_(\\d*)?_?(.*)-\\d*_.*$");
Matcher m = pattern.matcher(resourceFile.getName());

if (m.find()) {
    String destinationNickname = m.group(1);
    String jobnumber = m.group(2);
    String originalFileName = m.group(3);
} 

Test your regex with this site: http://www.regexplanet.com/simple/index.html