Merge numerous .txt files into one. Win/Cygwin - text

I have 500 .txt files and I need to merge them into 1 .txt file. I could do this manually by hand but it would take a long time. I'm wondering if there's an easier way via command line? I would need a new line character between each .txt file's contents in the end text file. I'm running Windows 7 but also have Cygwin installed.

You may place all the txt files into a folder.
Open Window CMD
Move to that folder and Run this command
for %f in (*.txt) do type "%f" >> output.txt
All the files will be merged into output.txt

Related

unziping files in linux folder

in Python I have the following command executed unzip '{dir}ATTOM_RECORDER/*.zip' -d {dir}ATTOM_RECORDER/ as a bash command. The python call works perfectly. my question is about the unzip command itself.
for some reason when unzip is called to expand any relevent zip files in the folder specified, not all the files WITHIN the zip is extracted. There's usually a rpt and a txt file. However, sometimes the txt file is not coming out and I do not have an error command.
How can I ensure the txt file is guaranteed to be extracted before moving on?
Thanks
While you want to unzip your specific zip file. There are many option to decompress any file from zip files. Easiest way is the ā€˜-lā€™ option with unzip command is used to list the contents of a zip file after extracting it.
Syntax: unzip -l [file_name.zip]

How to print all the file paths inside of a folder from linux command line

I have a very simple question about the linux command line. Say I'm in a folder in the terminal with 6 CSV files. I'd like to simply print out the contents of the folder with all of the paths to the six files listed. I'd like to use these paths to these files in my code to access them. What command would do this?
Would it be a modified LS command? I'd like to not use the 'find' command.

Excel vba - save as pdf and vba ftp upload - upload looks funny [duplicate]

currently im executing this batch for ftp -s:
open 192.1.2.3
USER
PASSWORD
cd "folder"
lcd "c:\folder"
prompt
mkdir 20140730
cd "20140730"
mput *.jpeg
quit
During testing I was trying to mput like 10 files and everything seems fine. Now im transfering aprox. 1400 files with total size 700MB and my problem is that uploaded file is different then the original one. JPEG seems to be corrupted, on some image is lighter part another part is dark, or there are some coloured lines or parts on image... Is there way check if files moved by mput are same with source files? All files i have checked are affected.
Issue the binary keyword in the script before transferring the files.
prompt
binary
The binary keyword stops files being truncated at the first EOF character, which is the default behaviour in text transfer mode.

Zip batch command and Excel

I have many excel files that I need zipped into each of their own zip folders. I thought I had this ironed out, but I have co-workers coming back to me saying that they cannot open the excel file because it has become corrupted. I went back and checked the original file, and it opens up just fine. But when I open up the same version of the file that was zipped, I too get the corrupted error. I'm on Office 2010, which is able to repair it, but my co-workers are all Office 2007 which does not seem to be able to fix the file. My batch code is as follows:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX" "%%X"
I think you might be using a wrong value as the first parameter to the 7zip executable. According to the documentation on FOR:
%~nI - expands %I to a file name only
And according to the 7zip documentation:
You can use the "a" command with the single letter a. This command stands for 'archive' or 'add'. Use it to put files in an archive. You have to specify the destination archive, and the source files (in that order).
So, using your script with an example file, it seems to me that your command line becomes:
"C:\Program Files\7-Zip\7z.exe" a -tzip "somefile.xlsm" "C:\path\to\somefile.xlsm"
Shouldn't the first parameter have a .zip file extension on the end? So the line is modified to look like this:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX.zip" "%%X"
As annoying as it is, file extensions actually mean something in Windows. Your previous line was creating a zip file with the .xlsm extension. When people try opening those files, Excel complains (because it's a zip file; not a .xlsm).
#Echo OFF
PUSHD "C:\Program Files\7-Zip" && (
FOR /R "%CD%" %%# in (*.xlms) DO (7z a -tzip "%%~n#.zip" "%%#")
POPD
)
REM Don't worry about the PUSHD command, the %CD% variable isn't expanded, that's the trick.
Pause&Exit
And you can use the dynamic operator * (asterisk) and 7zip -recursive parameter if you want all together in one file:
7z a -r -tzip "ALL.zip" "*.xlsm"
Sorry guys.
It was a false alarm. Turns out it wasn't all of the files, but only a select few. The files were sectioned out by region, and the only ones that were corrupt were the first region. Why? I can only assume that they were corrupted by my original attempts at making a batch file, as all the other files were zipped with the finished batch and thus didn't have errors. So nothing was wrong with my script. Thanks for the help though.

Bash Script for xls2csv

Scenario :
A folder in Linux system. I want to loop through every .xls file in a folder.
This folder typically consists of various folders, various filetypes (.sh, .pl,.csv,...).
All I want to do is loop through all files in the root and execute a program only on .xls files.
xls2csv is the program i need to run
for example:
i have 300 directories at /home/ftp_account/user1 up to user300 w/c contains .xls files in every folder,i want to convert all .xls files then move the converted files to /home/ftp_account/user1/converted
take note: converted files for user1 will go to /home/ftp_users/user1/converted
files for user2 will go to /home_ftp_users/user2/converted
files for user3 will go to /home_ftp_users/user3/converted
etc....
Please help!
Thanks guys :)
#!/bin/bash
for dir in /home/ftp_users/user{1..300}; do
for file in $dir/*.xls; do
fn=$(basename ${file})
fn=${fn%.*}
mkdir -p $dir/converted
xls2csv $file > $dir/converted/${fn}.csv
done
done

Resources