Notification when a file changes?

You can use the FileSystemWatcher class. public void CreateFileWatcher(string path) { // Create a new FileSystemWatcher and set its properties. FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = path; /* Watch for changes in LastAccess and LastWrite times, and the renaming of files or directories. */ watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; // … Read more

How to check command line parameter in “.bat” file?

You need to check for the parameter being blank: if “%~1″==”” goto blank Once you’ve done that, then do an if/else switch on -b: if “%~1″==”-b” (goto specific) else goto unknown Surrounding the parameters with quotes makes checking for things like blank/empty/missing parameters easier. “~” ensures double quotes are stripped if they were on the … Read more

recursively add file extension to all files

Alternative command without an explicit loop (man find): find . -type f -exec mv ‘{}’ ‘{}’.jpg \; Explanation: this recursively finds all files (-type f) starting from the current directory (.) and applies the move command (mv) to each of them. Note also the quotes around {}, so that filenames with spaces (and even newlines…) … Read more

What happens to an open file handle on Linux if the pointed file gets moved or deleted

If the file is moved (in the same filesystem) or renamed, then the file handle remains open and can still be used to read and write the file. If the file is deleted, the file handle remains open and can still be used (This is not what some people expect). The file will not really … Read more

How to extract filename.tar.gz file

If file filename.tar.gz gives this message: POSIX tar archive, the archive is a tar, not a GZip archive. Unpack a tar without the z, it is for gzipped (compressed), only: mv filename.tar.gz filename.tar # optional tar xvf filename.tar Or try a generic Unpacker like unp (https://packages.qa.debian.org/u/unp.html), a script for unpacking a wide variety of archive … Read more

How do I change read/write mode for a file using Emacs?

M-x read-only-mode in very old versions of Emacs, the command was: M-x toggle-read-only On my Windows box, that amounts to Alt-x to bring up the meta prompt and typing “read-only-mode” to call the correct elisp function. If you are using the default keyboard bindings, C-x C-q (which you read aloud as “Control-X Control-Q”) will have … Read more