Fix broken txt files from GREP reports - excel

I get a report from the companies servers (of which I have no control) in the form of grep txt dumps. I need to process them to get the info in a sane manner, which I use excel, and it works great.
Problem is, sometimes there are a few txt files that are broken, and cannot be processed with excel. Funny thing is, if I open them in notepad or something, copy all the data, create a new txt file, paste it all and there and process the new file, it works perfectly. Another curious thing is that when I do this, the new file which works, is a few kb's larger than the "broken" original.
My question is, is there a program, script or macro that I could use to
Open the text files in a folder
Copy the text of a file
Paste it in a new text file
Save that file with the same name as the original, in a different
folder
Rinse and repeat for each file in a folder
Any idea is a great help, I have thousands of files to sift through each month, and it really is quite a pain.

Turns out the files were in Unix format rather than windows one. I ran todos.exe and it fixed my problems.

Related

Batch file creation: Convert xls to csv using only batch script

I have done quite a bit of searching before posting this question so let me outline what I am trying to do.
1.) I do not want to use applications I have to download from a website or created custom commands (please no start Xls2Csv.exe here's a link to a website where you can download the program) I do not want to download a program to do this.
2.) I want to keep it in the batch file if possible - I have tried the vbc/vbs/vb files that is not what I am looking for.
3.) I found this an this is close to what I need but if I can stay within a batch file that would be best: Can a Batch File Tell a program to save a file as? (If so how)
Background
I have a bunch of test records stored in excel sheets within folders. Each test record has autoformatted name so the only real difference between any of the filenames is a serial number, otherwise each file name is formatted the exact same way.
I have written a batch file to search and find the files I need but I am stuck on obtaining a tiny bit of information in a .xls file.
What I am trying to do - I have excel files (.xls) and there is a word in a cell on one of many sheets that I would like to copy into a textfile. However I am unable to use findstr for an excel find because the command searches the file as if you opened it in notepad and the data I need is not present.
I am not concerned of data loss as long as I can get this tiny bit of information to a text file.
Otherwise what I have found to be the best solution is to convert an XLS to a CSV. I have manually done it by opening the file and saving as type .csv that worked.
What hasn't worked is:
example1.xls >> example2.csv
ren example1.xls example3.csv - this will save it as a csv file but still opens with the same formating of the xls file in both excel and notepad.
I was hoping that the was a command to recreate the manual process of opening the file and saving as csv.
If there are any other suggested solutions - maybe a command where I can search for a string within an excel file? That would be the simplest option.

Excel hangs/crashes while updating external link at file opening

I encountered this weird ass and funny error.
I built a file for data ETL. This one takes in various .csv files, combines them and export new .csv files using VBA. The file is originally named as "xxx Modelling ETL.xlsm". It could be opened normally till one day it hangs or crashes while trying to recalculating something (may be the underground query).
After hours of struggling, I opened the file as a copy (under a new name of Copy of ...). Strangely it ran smoothly, no crash or hang. Then I try rename it by remove the "Copy of" part, then the error occurs again.
I want to share this as there could be someone has the same problem, or someone who could shed some light on this black magic thing.
Some solutions:
Rename the file or move it to local drive instead of Onedrive makes thing works normally again.
Open Trust Center, disable Macro with notification, Trusted Locations, and Trusted Documents. Enable them for specific files when open, not for all.

Append text file with custom footer

Good day,
I am a CNC program not a computer programer. I am using CAM software to make cutting programs for our CNC router. The router is a bit old and can only take files 200-300 kb big. We are doing carvings that require 1-2 megs text files. I am using a program called GSplit ( http://www.gdgsoft.com/gsplit/ ) to divvy up the text file. It generates 10-25+ files with a custom header that our machine can read. All the files are great and it works, but I have to manually add the closing lines/footer to each file. The files that are created and used are normal .txt files but with a specific extension, .ANC.
Is there any way to automate this process of opening each individual file, scrolling to the end and copy/pasting the same 1-2 lines of code? The files are NAME[number].ANC in a contained folder. Would it be possible to just direct to a folder and say "add this 'text' to every file in this folder"?
Thanks for your time.
What OS are you using? Using Unix you can do a simple script on command line. If you are in the directory with the specific files simply execute:
for file in *; do echo "APPEND THIS" >> $file; done
If you are running Windows you should be able to do the same using cygwin (probably you could also use the power shell, but I don't know anything about the that)
I found a program Notepad++ (apparently the last person to find it...). USed the find/replace files option. A regular expression(note sure exactly what these are but I'm sure you guys do) "\s+\z" as to what to look for. It finds the last space or whatever at the end of all the files and then adds the code I need. Easy, free, and I don't need to write any computer code. Thanks for the attempt to help me Dirkk! :)

Zip file with .csv extention lost somewhere in filesystem

The file is also locked with winzip and I cant remember the name or directory, I hid it in a very obscure directory. Could be in the windows system files could be in a program directory file. I did a search for all .CSV files I have 4-5K to go through. Any suggestions on how this could be done?
I was opening up files in batches by highlighting a bunch that pressing edit with notepad plus plus. Than going through each one. I know once the file is opened in notepad plus it will not show any words. It is pictures. I own an eCommerce site and I have my master copies that I bought $X,XXX and did not want to take any chances in them be found and resold by other people on my network. Any suggestions?
Opening any zip file in a hex editor suggests that every zip file starts with a data of PK. We can use it in our favour. :)
Download this software: EditPad Pro
What this software does is, it recurses through the whole filesystem starting from a specified base folder to search for any string residing in any of the child files, they maybe Text or Binary, it treats them the same, thus giving accurate results.
In our case, it's a regex: ^PK
When you'll execute this search, the software will return all the files that start with data PK, make sure you do a casesensitive search.

mass convert Excel files into tab-delimited text files

Is there a tool to convert a large number of excel files into tab delimted files automatically?
I just through this together, its not pretty but should do what you need. Tested on WindowsXP / Office2007.
download from: http://stembro.byethost17.com/utility_scripts/xl2tab/xl2tab.html
Extract the xl2tab.vbs file to the directory containing the excel files and double-click to run. It will place the converted files into a new directory called "output." The original directory-structure remains intact within the output folder.
I don't think there are any good free tools to do so right now, but you could look into using the Open Office API to write something,
[http://www.oooforum.org/forum/viewtopic.phtml?t=7657&highlight=convert+xls+csv+command+line][1]
Or for a quick and dirty solution, you could record and Open Office Calc macro that would do it, and launch that macro from the command line.
This might also help http://dag.wieers.com/home-made/unoconv/
convert to csv, and maybe replace , with tabs?

Resources