batch remove periods from files

I had a user that had a folder of files that had a lot of .’s in the names.  As an example:
I.like.kayaking.txt
This.is.a.sample.file.txt

They needed all of the .’s replaced with a space.  Here is the contents of the batch file that I created to fix the issue:


@echo off
 setlocal enableextensions disabledelayedexpansion

for %%a in (*) do (
 set "filename=%%~na"
 setlocal enabledelayedexpansion
 for %%f in ("!filename:.= !") do (
 endlocal
 ren "%%~fa" "%%~f%%~xa"
 )
 )

All the user has to do is copy the .bat file into the directory that has the problem files and then run the .bat file.

This is a slightly modified version of the script found at: https://stackoverflow.com/questions/28558996/batch-file-for-replacing-dots-with-spaces-in-file-names

Shell script to concatenate multiple csv files

I had a unix directory with multiple CSV files, all with the same prefix.  I needed them to be concatenated together to make one large file using a shell script.

I used the below code, copied multiple times (one for each file prefix)

Sample files:
file20170804.csv
file20170803.csv
file20170802.csv


new_file=”/dir/file.csv”
if [ -f $new_file ] ; then
rm $new_file
fi

for file in /dir/file?*.csv
do
tail -n +2 “$file” >> $new_file
done


Here is the code with comments:

1 new_file=”/dir/file.csv”
2 if [ -f $new_file ] ; then
3 rm $new_file
4 fi

5 for file in /dir/file?*.csv
6 do
7 tail -n +2 “$file” >> $new_file
8 done

1 – Name of the file you are creating
2 – 4 Check if the file already exists.  If so, then remove it
5 Loop through the smaller files.  Note that I have a ? to make sure that it is not trying to add the big file back to itself.
6-8 Concatenate the file to the $new_file, but ONLY lines 2-end of file.  This omits the header record of the .csv file.