Bash script to append a .txt extension to a filename
for i in *.log*; do mv "$i" "$i.txt"; done
Iterate over the current directory, get all files with .log and append .txt to the end of the entire filename:
for i in *.log*; do mv "$i" "$i.txt"; done
Iterate over the current directory, get all files with .log and append .txt to the end of the entire filename:
/// <summary> /// Counts the lines of a File. /// </summary> /// <param name="fileToCount">The file to count.</param> /// <returns>lines of a File</returns> private static int CountLines(string fileToCount) { int counter = 0; using (StreamReader countReader = new StreamReader(fileToCount)) { while (countReader.ReadLine() != null) counter++; } return counter; }
/** * Tests, if given filename is valid * * @param string $filename * @return bool */ public static function isValidFilename($filename) { return (bool) preg_match('/^[a-z0-9_ ]{1,30}.[a-z]{1,3}$/i', $filename); }
Tests, if a given filename is valid.
for i in *.txt; do echo $i"foo"; done
Lists all files and appends "foo" to every file (only on the output).
String fullPath = Path.GetFullPathInternal(path); // For security check, path should be resolved to an absolute path. new System.Security.Permissions.FileIOPermission(FileIOPermissionAccess.Write, new String[] { fullPath }, false, false ).Demand();
Most popular snippets