filenames

How to handle filenames with spaces?

那年仲夏 提交于 2019-11-28 12:12:07
I use Perl on windows(Active Perl). I have a perl program to glob the files in current folder, and concatenate them all using dos copy command called from within using system()... When i execute, this gives a dos error saying "The system cannot find the file specified." It's related to the spaces in the filenames I have. This is the perl code :- @files = glob "*.mp3"; $outfile = 'final.mp3'; $firsttime = 1; foreach (@files) { if($firsttime == 1) { @args = ('copy' ,"/b ","$_","+","$outfile", "$outfile"); system (@args); #system("copy /b '$_'+$outfile $outfile"); $firsttime = 0; } else { @args =

Deleting filenames that have space and special characters

痞子三分冷 提交于 2019-11-28 12:05:41
问题 I have a large filelist of 7000+ files to delete from a Unix directory. I could have accomplished this using a while loop while read file do rm $file done < filelist or just cat filelist | xargs rm The challenge comes from deleting those files which have "Windows-like back slash \, colon : and spaces " in their filenames. Eg. C:\Sxxx Accr Vac 1111.txt N:\Lxxx\Dxxx_FOLDER\Mxxx\Mxxx_DOWNLOAD_TEXTFILE_PATH\000000_Mxxx_Bxxx-Pxxx-H.txt N:\Lxxx\Dxxx_FOLDER\Mxxx\Mxxx_DOWNLOAD_TEXTFILE_PATH\130607

What does “?”, used after JavaScript filename, means?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 12:02:38
For example, having: <script type="text/javascript" src="http://somedomain.com/js/somejs.js?14"> </script> So what does "?14" means here? Its a url param like any other parameter passed in a url. Sometimes JS scripts are created on the fly using server side technologies other times it is simply a version number to help with browser caching issues. They are there to fool browsers into thinking that it is a new file. This is a trick to avoid browser-cached copy when you update the JS file. The javascript script is probably generated by a server side script (PHP, CGI, etc.) , which takes 14 as a

Listing files in date order with spaces in filenames

房东的猫 提交于 2019-11-28 11:50:22
I am starting with a file containing a list of hundreds of files (full paths) in a random order. I would like to list the details of the ten latest files in that list. This is my naive attempt: $ ls -las -t `cat list-of-files.txt` | head -10 That works, so long as none of the files have spaces in, but fails if they do as those files are split up at the spaces and treated as separate files. File "hello world" gives me: ls: hello: No such file or directory ls: world: No such file or directory I have tried quoting the files in the original list-of-files file, but the here-document still splits

Extract file name from full path in C using MSVS2005

[亡魂溺海] 提交于 2019-11-28 11:43:30
In a C program, I have a file path in a string (specifically, this is the exe name stored in argv[0] ). I would like to extract the file name and discard the directory path using MS Visual Studio 2005. Any built in function for that? Not really, just locate the last backslash in the path. Anything after that is the filename. If nothing is after that, the path specifies a directory name. // Returns filename portion of the given path // Returns empty string if path is directory char *GetFileName(const char *path) { char *filename = strrchr(path, '\\'); if (filename == NULL) filename = path; else

Name variable based on string MATLAB

巧了我就是萌 提交于 2019-11-28 10:46:37
问题 I have a variable that is created by a loop. The variable is large enough and in a complicated enough form that I want to save the variable each time it comes out of the loop with a different name. PM25 is my variable. But I want to save it as PM25_year in which the year changes based on `str = fname(13:end)' PM25 = permute(reshape(E',[c,r/nlay,nlay]),[2,1,3]); % Reshape and permute to achieve the right shape. Each face of the 3D should be one day str = fname(13:end); % The year % Third

Python - WindowsError: [Error 2] The system cannot find the file specified

浪尽此生 提交于 2019-11-28 10:34:33
问题 I have a folder full of pdf files. I'm trying to remove all the spaces from files name and replace them with underscores. Here's what I have so far: import os, sys folder = path to folder FileList = os.listdir(folder) for files in FileList: if ' ' in files: NewName = files.replace(" ", "_") os.rename(files, NewName) When I run this script I get the following error: WindowsError: [Error 2] The system cannot find the file specified I'm guessing there is a pretty simple fix, but I've look all

Can I find a filename from a filehandle in Perl?

六月ゝ 毕业季﹏ 提交于 2019-11-28 09:43:00
open(my $fh, '>', $path) || die $!; my_sub($fh); Can my_sub() somehow extrapolate $path from $fh? A filehandle might not even be connected to a file but instead to a network socket or a pipe hooked to the standard output of a child process. If you want to associate handles with paths your code opens, use a hash and the fileno operator, e.g. , my %fileno2path; sub myopen { my($path) = @_; open my $fh, "<", $path or die "$0: open: $!"; $fileno2path{fileno $fh} = $path; $fh; } sub myclose { my($fh) = @_; delete $fileno2path{fileno $fh}; close $fh or warn "$0: close: $!"; } sub path { my($fh) = @_

How to handle spaces in filenames using double quotes in a Bash script

≡放荡痞女 提交于 2019-11-28 09:33:42
问题 We have a script running on our Debian server that grabs filenames in a directory and pushes them to our API. It runs fine when filenames don't have spaces. The usual answer to this common issue is to use double quotes around the variable name. However, I can't find a tidy, brief and definitive solution for our particular case—code below. Although this answer has suggests changing the separator from space to \n , I'd rather get the double quote method right in our existing code. Here's the

VisualStudio project with multiple sourcefiles of the same name?

依然范特西╮ 提交于 2019-11-28 09:21:55
i have a largish C++ project, with source-files organised in multiple folders (on the filesystem). in two of these folders, i have files with the same name. e.g. \MyProject\foo\Blurp.cpp \MyProject\foo\File.cpp \MyProject\bar\File.cpp \MyProject\bar\Knoll.cpp the project is cross platform, and i use autoconf on linux and OSX, but have to use MSVC on W32 (due to some 3rd party C++ libraries i use on W32 and the C++ binary interface incompatibilities across compilers) on the MSVC side, the project is organized into multiple "Filters" (those virtual Folders) as well (with names roughly