filenames

Check if an absolute path of a directory or a file name are valid

痴心易碎 提交于 2019-12-08 03:28:21
问题 I'm creating a bat script and I should check whether a variable contains a valid absolute path of a directory and if another variable contains a valid name of a file for Windows 8 and above. So, how would I go these checks? Thanks Bye 回答1: This is much trickier than most people realize. There is lots of misinformation about this topic available on SO and elsewhere. There are many "solutions" that appear to work, but then fail under certain circumstances. The problem can be divided into two

Git diff fails on file with underscore in path

≡放荡痞女 提交于 2019-12-07 16:13:57
问题 I'm running Windows 7, and I have the latest version of git (2.7.2.windows.1). I previously used Windows PowerShell as my terminal for git operations, with no issues. Recently, I decided to switch to Git Bash, but I'm having one major issue. My project has a directory (within which are many subdirectories) whose name is simply an underscore. Whenever I try to run git diff on a file within that directory, I get the following error: $ git diff _/css/templates/jquery.tag-editor.css fatal:

file name with special characters like “é” NOT FOUND

寵の児 提交于 2019-12-07 14:39:18
问题 I have a folder on my website just for random files. I used php opendir to list all the files so i can style the page a bit. But the files that I uploaded with special characters in them don't work. when i click on them it says the files are not found. but when i check the directory, the files are there. seems like the links are wrong. any idea how i can get a correct link to these file names with special characters in them? 回答1: This is tricky. It depends what encoding your filesystem uses

How to control base64 images when user saves as

房东的猫 提交于 2019-12-07 09:55:07
问题 I'm making an app where i want to show the user a range of base64 encoded picture. They are shown by using data-url. If the user wants to save a picture, it can simply rightclick and save as (or drag it into a folder). Are there any way to control the sugested filename? Right now Chrome just sugest "download" and doesn't even recognize it as an image. Can this be done in any way? I only need it to work in Chrome. Thanks for any help 回答1: Make sure you are setting the proper mime type for the

Getting the name & extension of an uploaded file using python (google app engine)

此生再无相见时 提交于 2019-12-07 08:19:32
问题 I am using a form to upload files to the google app engine and store them in the datastore. l would also like to store the original file name and extension for presentation purposes. Is there a way of retrieving this data from the post sever side or can it only be gathered client side and sent as separate fields (e.g. http://www.tinyurl.com/5jybfq)? Many thanks. For those that follow the solution dased on the answer below: this_file = self.request.params["file_upload_form_field_name"]

Any rules about underscores in filenames in C/C++? [closed]

北战南征 提交于 2019-12-07 07:28:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 months ago . I know that there are rules for using underscores in identifiers in C/C++. Are there any rules for using them in source code filenames? For instance, are there any restrictions against beginning or ending a filename with an underscore? Or having an underscore as the last

Using urllib2 in Python. How do I get the name of the file I am downloading?

浪尽此生 提交于 2019-12-07 05:51:42
问题 I am a python beginner. I am using urllib2 to download files. When I download a file, I specify a filename to with which to save the downloaded file on my hard drive. However, if I download the file using my browser, a default filename is automatically provided. Here is a simplified version of my code: def downloadmp3(url): webFile = urllib2.urlopen(url) filename = 'temp.zip' localFile = open(filename, 'w') localFile.write(webFile.read()) The file downloads just fine, but if I type the string

UTF-8, PHP, Win7 - Is there a solution now to save UTF-8-filenames on Win 7 using php?

丶灬走出姿态 提交于 2019-12-07 05:19:44
问题 Update: Just to not make you reading through all: PHP starting with 7.1.0alpha2 supports UTF-8 filenames on Windows. (Thanks to Anatol-Belski!) Following some link chains on stackoverflow I found part of the answer: https://stackoverflow.com/a/10138133/3716796 by Umberto Salsi (and on the same question: https://stackoverflow.com/a/2950046/3716796 by Artefacto) In short: 'PHP communicate[s] with the underlying file system as a "non-Unicode aware program" ', and because of that all filenames

How to swap filenames in Unix?

一曲冷凌霜 提交于 2019-12-07 02:26:04
问题 Any way to do this quickly without using a temp variable? Is there a built in function? Edit: Thanks for the answers guys. Looks like I need to clarify my question but for the most part you guys assumed correctly: There are two files and the filenames names are reversed. File A has name B-name.file File B has name A-name.file I'd like for File A to be named A-name.file and File B to be named B-name.file. I agree, the situation doesn't happen often but it just happened to me and I wanted a

Move a group of files to a new folder if their file names, minus extension, matches?

不羁岁月 提交于 2019-12-06 15:35:21
问题 I have a folder full of files that have the same name but different file extensions. For example: file-1.ai file-1.svg file-1.pdf file-2.ai file-2.svg file-2.txt file-3.ai file-3.svg example-1.pdf example-3.mov Is there any way in Linux (any programming language will do) I can move the group of files to a new folder (either a new folder per file group or all in one folder) if their file names, minus extension, matches? 回答1: Think you want something like this. #!/bin/bash dir="/somedir/" for i