file-manipulation

Rename files in sub directories

Is there any way of batch renaming files in sub directories? Example: Rename *.html to *.htm in a folder which has directories and sub directories. ...

How can I recursively copy files of a specific pattern into a single flat folder on Windows?

I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder. I want to use built in Windows tools, e.g. DOS commands. Thanks in advance. ...

Best Awk Commands

I find AWK really useful. Here is a one liner I put together to manipulate data. ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext > " $1 ".new_ext" }' > file.csh I used this AWK to make a script file that would rename some files and only print out selective columns. Anyone know a better way to do ...

php file manipulation functions fails on my localhost saying permission denied

im running on windows xp and i am an administrator, im using the latest xampp bundle available from their site and i receive these kinds of errors when i use file manipulation functions on php... Warning: chmod() [function.chmod]: Permission denied in... Warning: opendir(/feeds) [function.opendir]: failed to open dir: Permission denied ...

How do I download javascript string as a file

Application requests KML data through AJAX from server. This data is stored in javascript variables, and displayed in Google Earth plugin. In javascript, how do I provide a link to download the KML data stored in javascript variable (as a string) without requiring a request back to server? This link: http://forum.mootools.net/viewto...

How to reliably handle files uploaded periodically by an external agent?

It's a very common scenario: some process wants to drop a file on a server every 30 minutes or so. Simple, right? Well, I can think of a bunch of ways this could go wrong. For instance, processing a file may take more or less than 30 minutes, so it's possible for a new file to arrive before I'm done with the previous one. I don't want...

Creating a 'New File Windows' behavior

Hi guys, in a windows environment and in several applications, when we create a new file with the same name of an existing file, the user is not prompted with a message that the output file already exists, but it creates a new file with (1) at the end of the filename... name.doc will be name(1).doc I'm trying to create the same be...

How to do this in PowerShell? Or : what language to use for file and string manipulation?

What language should I use for file and string manipulation? This might seem objective, but really isn't I think. There's lot to say about this. For example I can see clearly that for most usages Perl would be a more obvious candidate than Java. I need to do this quite often and at this time I use C# for it, but I would like a more scr...

Saving results of Regex Search into a file with Vim

I've got a HTML file, and I'd like to grab all the links that are in the file and save it into another file using Vim. I know that the regex would be something like: :g/href="\v([a-z_/]+)"/ but I don't know where to go from here. ...

Split Files using tar ,gz,zip or bzip2

Hello, i need to compress file and it's giganitc file :D the size is about 17-20 GB i need to split it to files in size around 1GB for each part , i tried to googleit and found way using split,cat command and it did not work at all in large files , also it wont work in Windows i need to extarct it on windows machine, thanks in advance ...

Linux command for removing all ~ files

What command can I use in linux to check if there is a file in a given directory (or its subdirectories) that contain a ~ at the end of the file's name? (Example if I am at a directory called t which contains many subdirectories, etc, I would like to remove any file that ends with a ~) ...

Renaming files during ANT copy

I'd like to copy a directory of files, and rename some of them in the process. When I run the script below, nothing copies. If I comment the glob mappers in the file below, the files are copied (without the renaming) Thanks for any help. James <?xml version="1.0" ?> <project name="Create project structure" default="main"> <target nam...

Fast way to add line/row number to text file

I have a file wich has about 12 millon lines, each line looks like this: 0701648016480002020000002030300000200907242058CRLF What I'm trying to accomplish is adding a row numbers before the data, the numbers should have a fixed length. The idea behind this is able to do a bulk insert of this file into a SQLServer table, and then pe...

Does Directory.GetDirectories(path) return full paths or just names?

In the MSDN documentation, it says it returns just directory names("Return Value Type: ... An array of type String containing the names of subdirectories in path."), however in their example code, they recurse without concatenating them, so does that mean they return the full paths? i.e. their example code: public static void ProcessDi...

Codeigniter and uploading zip files

Hello, I am currently building a backend to a site using the codeigniter framework, I have hit a bit of a problem, I needing a way to allow the user to upload a zipped folder of images, on completing the form, zipped folder must be unzipped, and the files need to be moved to a folder else where on the server, have thumbnail version of e...

Adding text to start of each new line in a .txt file

I would like to add a predefined text to each new line on a text file and create a new text file with the added text. Please help. ...

Java File manipulation

So I have an application with a JFileChooser from which I select a file to read. Then I change some words and write a new file. The problem that I am having is that when I write the new file it's saved in the project directory. How do I save it in the same directory as the file that I chose using the JFileChooser. Note: I don't want to u...

bash, Linux: Set difference between two text files

Hi, I have two files A-nodes_to_delete and B-nodes_to_keep. Each file has a many lines with numeric ids. I want to have the list of numeric ids that are in nodes_to_delete but NOT in nodes_to_keep, e.g. . Doing it within a PostgreSQL database is unreasonably slow. Any neat way to do it in bash using Linux CLI tools? UPDATE: This woul...

Python newbie: trying to create a script that opens a file and replaces words

Hi, im trying to create a script that opens a file and replace every 'hola' with 'hello'. f=open("kk.txt","w") for line in f: if "hola" in line: line=line.replace('hola','hello') f.close() But im getting this error: Traceback (most recent call last): File "prueba.py", line 3, in for line in f: IOError: [Errno 9...

Text Manipulation Split Classes in a Single File into mulitple Files

I used XSD.EXE to to generate a C# files from an XSD schema. Unfortunately, this tool extracts all the classes into a single allClasses.cs file. Has anyone got a good technique(or tool) that will extract each of the classes in the allClasses.cs file into their own respective file e.g. ClassA.cs, ClassB.cs, etc. ? ...