filenames

Bash script to replace spaces in file names

Can anyone recommend a safe solution to recursively replace spaces with underscores in file and directory names starting from a given root directory? For example, $ tree . |-- a dir | `-- file with spaces.txt `-- b dir |-- another file with spaces.txt `-- yet another file with spaces.pdf becomes $ tree . |-- a_dir | `--...

DBD::CSV: Problem with file-name-extensions

In this script I have problems with file-name-extensions: if I use /home/mm/test_x it works, with file named /home/mm/test_x.csv it doesn't: #!/usr/bin/env perl use warnings; use strict; use 5.012; use DBI; my $table_1 = '/home/mm/test_1.csv'; my $table_2 = '/home/mm/test_2.csv'; #$table_1 = '/home/mm/test_1'; #$table_2 = '/home/mm/tes...

PHP mp3 upload with spaces in filename

Hi folks, I am building a site, where users can upload their mp3s and I ran into a little problem that I can't solve: The upload works fine, but only when the user selects an mp3-file which has no spaces in their mp3-filename. A file like 'My nice mp3 file.mp3' will result in a NULL of $_FILES['file']. Has this to do with Server-config...

Can I find a filename from a filehandle in Perl?

open(my $fh, '>', $path) || die $!; my_sub($fh); Can my_sub() somehow extrapolate $path from $fh? ...

how I create a random image name c#

when I add a picture I want it to create a new random name because if you add a picture with the same name it will just overwrite ...

Safely escaping and reading back a file path in ruby

I need to save a few informations about some files. Nothing too fancy so I thought I would go with a simple one line per item text file. Something like this : # write io.print "%i %s %s\n" % [File.mtime(fname), fname, Digest::SHA1.file(fname).hexdigest] # read io.each do |line| mtime, name, hash = line.scanf "%i %s %s" end Of course...

How can I stop sorl thumbnail from breaking with very long filenames?

I've noticed that when working with SORL thumbnail, sometimes a user will upload an image with a very long filename, longer than the varfield in the database can hold. The name gets truncated in the database and the project gives errors whenever the image is requested. Is there a smart and safe way to have django automatically truncate ...

What's the standard config file name and extension in Python?

I'm creating a config file to hold configuration/properties settings for my project that frequently change, such as file paths. What's the standard name/extension for such a file? (e.g. in Java I've used config.xml, in VB.NET I've used App.config...) ...

Get the image file path

HI, I am trying to retrive the filname of the image file from a file path in my code. My filepath: c:\mydocuments\pictures\image.jpg which method can i use in c# to get he filename of the above mentioned path. Like String file = image.jpg I have used the system.drawing to get he path, but it returns null. my code: string file = Sy...

Problem with RegEx.Replace and trying to change a filename

Hello, I am having a strange problem and I can't seem to figure it out. My filename is something like this: DER 1513016-3.020F.NCF. I want to be able to change it to: DER 1513016-3.020H.NCF Sometimes the filename can be this as well: DER 1513016-3.020F_NEW.NCF which would change to: DER 1513016-3.020H_NEW.NCF This is my code ...

Replace %20 with spaces when downloading files?

Is it possible to get a url/downloaded file name change the "%20" to spaces? Like instead of downloading the file my%20file.pdf, download my file.pdf? I'd like to use PHP if possible... ...

how to rename filename in sdcard with android application?

In my Android application, I want to rename the file name at runtime. How can I do it? This is my code: String[] command = {" mv", "sun moon.jpg"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo...

Is there a more correct type for passing in the file path and file name to a method

Hi What I mean by this question is, when you need to store or pass a URL around, using a string is probably a bad practice, and a better approach would be to use a URI type. However it is so easy to make complex things more complex and bloated. So if I am going to be writing to a file on disk, do I pass it a string, as the file name a...

Changing default logical filename in SQL 2005

I have a issue about creating databases in SQL 2005. I want to be able to change the default logical filename for the mdf file. At the moment the log logical filename ends in _log by default. I want the data logical filename to automatically end with _data for consistency. Is there a way i can set this? Andrew ...

xcopy directories and subdirectories recursively and filter only filenames by extension

Here is what i have for now: xcopy "c:\projects\SampleProject" "c:\temp\copytest" /E /H /EXCLUDE:elist.txt It does all the job i need except filtering filenames by extensions. For example: copy all *.exe files from c:\temp\copytest and subdirectories. How to do that? ...

Retrieve DTE2 ProjectItems

How can I retrieve a file (ProjectItem) from the _applicationObject given its full path, filename, or any other property obtainable via Item.Properties.Item("PropertyName")? Surely I don't have to loop through each item in the project until I find a match? ...

Is there a problem with the Gnuwin32 port of "find"?

Is there a problem with the Gnuwin32 port of "find"? It sort of works on my Windows XP command line, but I get blank stares when I try using file name pattern matching function. It's from "findutils-4.2.20" package. Had to rename to "gfind.exe" so Windows wouldn't confuse with CMD.EXE's "find". Some samples from my Windows console: C...

java filenames filter pattern

Hello, I need to implement File[] files = getFiles( String folderName, String ptrn ); Where ptrn is a command prompt style pattern like "*2010*.txt" I'm familar with FilenameFilter class, but can't implement public boolean accept(File dir, String filename) because String.matches() doesn't accept such patterns. Thanks! ...

int to string conversion

I would like to save files with different names in a loop. I use a library that needs a char as a parameter of the file... for(int i=0;i<nodes;i++){ for(int j=0;j<nodes;j++){ char a[20]="test"; char c[20]="xout.dat"; Lib::SaveFile(_T(a), _T(c)); }} The above code works, but I would like to change the name of the xout.mid to th...

How to include the server name in the filename of an apache log?

Hi - I want to configure apache so that the access and error logs generated from apache include are named as follows: <server-name>_access_<timestamp> <server-name>_error_<timestamp> I have the timestamp part figured out using rotatelogs: CustomLog logs/access_log combined CustomLog "|bin/rotatelogs -l /var/logs/access_%Y-%m-%d 8640...