Skip to main content

Posts

Showing posts from February, 2020

PowerShell playing with files and folder properties

 PowerShell code below shows how to work or play with files and folders.  #Get the file name only using “.BaseName” $FileNameOnly = ( Get-ChildItem -File -Path "C:\temp\" ) . BaseName #Get the full path of the file using “.FullName” $Full_Path = ( Get-ChildItem -File -Path "C:\temp\" ) . FullName #Get the parent folder of the path of the file using “.DirectoryName” $ParentFolder = ( Get-ChildItem -File -Path "C:\temp\" ) . DirectoryName #Get the file with the extension using “.Name” $FileName_withExtension = ( Get-ChildItem -File -Path "C:\temp\" ) . Name `n – starts a new line after the current line Write-Output "FileNameOnly: $FileNameOnly `n" Write-Output "Full_Path: $Full_Path `n" Write-Output "ParentFolder: $ParentFolder `n" Write-Output "FileName_with_Extension: $FileName_withExtension `n" Write-Output "**********`n" ...

Check permission of the current directory in Linux

Checking permission of a current directory in Linux is quite simple and basic. The "ls" command will do the job. ls does not require sudo membership to use the command. Even if a directory has no files on it, just type: ls -lad This will show the permissions on the current directory where the command is typed. Even if the directory has no files or it is empty it will show the folder permissions. Consult "man ls" why ls -lad works to check permissions on empty folders. Typing, ls -ltr won't show anything if the folder is empty. Typing, ls -lad will show the permission whether the folder is empty. The ls command will display "." the current folder and ". .", basically this will show the hidden files and it's current permission settings. But by typing ls only or ls -ltr it won't show any permissions if the folder is empty since there are no files to display and thus no information is displayed. Cheers. Till next time....

Concatenate all CSV files or combined all csv files to a single file

CSV files are basically text files which can be opened on a spreadsheet like Excel, Google Sheets online or any of its equivalent. A notepad editor can open a CSV files but it's formatting won't look great. By using Excel or Google sheets to open a CSV file it will look nice and won't look daunting to work with the file. Opening multiple CSV file and copying the contents to a single Excel is quite tedious and not efficient. So, how to make things easier? A simple copy command will concatenate CSV files into a single file. Here's how to do it in Windows. Copy all the CSV files into an empty directory. Open command prompt and browse to the directory where the CSV files are located. Ex: cd CSV_Directory At CSV_Directory, type this command: copy *.csv csv_files_in_oneFile.csv After pressing enter key all the CSV files within that directory will be concatenated to "csv_files_in_oneFile.csv". So, basically the sy...