Checking File Type

How would i check the file type of a file they selected to make sure its a .txt file? Thanks - Jeff

or a better way would just be
if(!filename.endsWith(".txt"))
    return;Cheers,
Radish21

Similar Messages

  • Check file type after JavaScript File.openDialog()...

    So, I'm on Mac OS and want my script to obviously cancel on the "Cancel" bottle, as well as check whether the file selected was a PDF. I've had some success with the code below, but some of the PDF's I select get cancelled with this script. Upon checking, the FilePath.type property returns "????" for some PDF's - anyone know why?
    var myFilePath = File.openDialog("Please choose a PDF file...", undefined, false);
    if((myFilePath == "") || (myFilePath == null)){
        exit();
    else if(myFilePath.type != "PDF "){
        alert("Please choose a PDF file!") ;
        exit();
    I'm quite new to scripting. Thank you!

    Under Windows, all you can do is supply a file extension (the well-known "*.PDF" filter), and it's wise to always add the catch-all "*.*" for 'All files'. That way, a user can select a file even if it has the wrong extension (and in that case, it's the user's responsibility to make sure the file is of the expected type nevertheless).
    Under OSX, there are two options:
    1. The file has the correct "Creator/Type" metadata; and/or
    2. The file has the correct file extension.
    Historically, Macintosh-based OSes used option #1, and software was not expected to look at the actual file names. However, that soon became unworkable when people tried to exchange files between their Mac and (virtually any) other systems. That lead to various tools to 'assign' Creator/Type data to well-known file extensions, just so they could be opened with the right software on a Mac. Also the reverse happened; saving a file 'without extension' on a Mac was not a problem, but to open it on Windows you often had to add the right extension.
    So, somewhere around one or two System versions ago, Apple decided to go back to the old, trusted 'File Extension' way. But OSX still saves Creator/Type metadata for files created on your own Mac. Checking the "type" should work then -- but the problem is, what if you got your file from somewhere else? The extension may be correct, but if it has no file type, your script will not see it.
    Fortunately, the Mac OSX File Open dialog allows some pretty wicked customizations. Never mind a file filter, you can run a custom function that decides for each separate file and folder whether it should be selectable or not. The function has access to all file attributes; you can go so far as to checking the file name, and reject all files that contain a 'q', or files that are read-only, or files that are smaller than 1Kb.
    Check out this piece of code (I wrote it myself, but various hints and tricks were read on this very forum):
    if (File.fs == "Windows")
        pdfFile = Folder.myDocuments.openDlg( 'Load PDF document', "Adobe PDF:*.pdf,All files:*.*", false);
    else
        pdfFile = Folder.myDocuments.openDlg( 'Load PDF document', function(file) { return file instanceof Folder || (!(file.hidden) && (file.name.match(/\.pdf$/i) || file.type == "PDF ")); }, false );
    (I advise you to copy the Windows fragment as well, just in case your script goes 'round the world.)

  • Quicktime 4.7 file type association hijacking

    I've got a really annoying little problem after upgrading to 7.6:
    The update also updated quicktime ( to 4.7) with ALL file types associations active. Arrogant to say the least, but just a nuisance nothing more.
    Problem is that I can't change them back: when I choose the default associations, click apply, click ok. And then when open the preferences panel again: they're all back
    Any solutions? I really don't want to be using quicktime for all my multimedia files: it's a terrible program (too bad it's mandatory for iTunes).
    TIA,
    Dietbrand

    I also have MAJOR problems with PictureViewer as of late. Not only does it have the 1993 file names limited to 8 characters (which I think is a problem with the installer/registry - it puts "C:\PROGRA~1\QUICKTI~1\..." as the path to it by default, whereas the older versions didn't do that.).
    Also, recent versions of Nvidia's Forceware Drivers (I upgraded from 94.24 (July '07) to the latest 169.xx since I'm getting a new video card), cause PictureViewer to crash ONLY when it loads the stupid little "Buy Quicktime Pro" box. Perhaps this could be disabled or made not to crash? Pictureviewer is (soon to be was) my default/preferred image viewer for every image type.
    Oh and there's a third problem with the new PictureViewer/QT combo, even if you tell PictureViewer to open a .gif, it will still load in QT (which I think has to do with QT's file association hijacking), unless I manually went into the registry and changed the associated within QT's part of the reg.
    As for QT. This file hijacking thing is unbelievable. The "do not show this message again" button to stop checking file types on PictureViewer has NEVER worked. Why even have the option if you can't say no? Also, the buttons/checkboxes in the control panel/qt preferences do nothing, it auto reverts as soon as you exit the menu and I'm guessing it doesn't change anything in the registry. Also, even when QT is first installed, it default only takes over MAC-related formats. On the first run of PictureViewer though, it gives the "some file associations were changed" message? By what program, the QT installer? When you press Yes to restore (b/c it's the only way to prevent the popup), it auto takes over EVERY file format QT recognizes... ugh.
    Thank god there is QT alternative. Anybody know any alternatives to PictureViewer that open pictures in new windows?

  • Get file Type

    Hi
    Need to get the Check file type into a varaible .
    eg  : '.TXT'     or  '.WTX'   etc from a path C:\Documents and Settings\name\desktop\file.txt  or file.wtx etc ....
    Thanks,
    Vind

    To make this happen follow the following code.
    SPLIT p_file AT c_dot INTO lv_file lv_ext.
    TRANSLATE lv_ext TO UPPER CASE.
    Here p_file is the variable containing the file path data.
    In our case lv_ext is the variable which would contain the type of the file you have selected.
    Reward if found use full.
    Thanks & Regards,
    Rama Murthy.P

  • ITune file type

    I have approximately 2,000 songs managed in by iTunes. Some have been downloaded as mp3 and others as AAC file types. Is there an easy way to seperate the library by file type?

    Control-click on the column header. In the box that comes up, check File Type. This will add a column in iTunes. You can then sort on that column by clicking on the column header.

  • How to check the type of uploaded file

    Hi, experts,
    how can I check the type of the uploaded file? I am dealing with exception handling now: when user uploads a type of file which is not allowed, then error msg shows up. So first I have to retrieve the type of the uploaded file.
    Best regards,
    Fan

    Best approach would be to control the file upload program. Here in force user to chose only the kind of file supported.
    If you are using WD4A & fileupload UI element, then after user select a file to upload, before processing the file you can check the file name and get its MIME TYPE as shown below.
    example
    data type file string.
    data dot_offset type i.
    data extension type mimetypes-extension.
    data mimetype type mimetypes-type.
    file = 'Image.jpg'.
    " Find out file name extension
    find first occurrence of regex '\.[^\.]+$' in file match offset dot_offset.
    add 1 to dot_offset.
    extension = file+dot_offset.
    " Get mime type
    call function 'SDOK_MIMETYPE_GET'
      exporting
        extension = extension
    importing
        mimetype  = mimetype.
    later using if/else or CASE statement define your logic.
    Greetings
    Prashant
    P.S. Points Welcome

  • Question about filtering a file type on check in?

    I am reading on how to filter file types on check in and I was wondering.  Is it possible to check a file type and pop up a error page in iDoc, or would I have to go the custom component route (and would that need to be java or iDoc)?

    Thanks for the input, but seeing how the setting where I'm going to employ this component for UCM is secure I can't use code I can't read for myself (No offence to the author of that blog or to you).  But yeah I kinda figured making a filter based component would be the best route, but most examples I've found used the intradoc library.  Problem is I can't seem to find the intradoc library to try to write a basic example to see what I'm doing, everything I get is for RIDC (even found a small example on writing a filter for RIDC).  Is this what UCM is using now in 11g?
    Also one thing I felt missing when looking at example code, I get the basic idea of the code itself.  But to employ the componant to work on the check in request would I just include that component in that idoc function for checkin?

  • File type check before uploading a file

    Right now I have a processing page that uploads a file only of type zip. If you try submitting something other than a zip file, it throws an error. Is it possible to check the file type before uploading?
    Something like this in pseudo code:
    if (file type does not = zip ) {
         redirect to the homepage with cflocation
    else {
         <cffile action="upload" ....  />

    Not with ColdFusion, it does not run on the client and has no idea about the file until the client browser has sent it to the web server and the web server as put it into the server's temp directory.
    Maybe with someting that runs on the client, like JavaScript.  But when dealing with files in the client browser you quickly run into security features that prevent you from doing much to prevent hackers from writing client code to farm unsupecting users systems for interesting files.

  • File type in GUI_download

    Hi Experts,
    Whatis the coresponding file type for 'WK1 for WS_DOWNLOAD in GUI_DOWNLOAD?

    Hi ravi,
    1. Its the same WK1.
    2. U can check for yourself in the documentation of this parameter in se37.
    regards,
    amit m.

  • Removing obsolete file type associations from "Open With" menu

    Ever since I removed VMWare Fusion 3.x from my system, I've been unable to remove the Bootcamp file type associations that it created. For example, if I right-click on a PDF and choose Open With, this is a partial list of what I see:
    Adobe Acrobat Pro (default)
    Adobe Distiller (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Fireworks CS4
    Adobe Fireworks CS4 (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Illustrator CS4
    Adobe Illustrator (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Photoshop CS4
    Adobe Photoshop CS4 (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    ...and on and on and on. 17 additional entries for Fusion for PDS's alone. This junk is driving me crazy.
    I've tried rebuilding the Launch Services database with MacPilot and Onyx (the recommended fix that I've found on the web), but the entries still are there even after restarting Finder and rebooting my iMac. I'm at a loss to figure out how to get rid of these.
    Can anyone help me?
    Thanks!

    They are stored in the LaunchServices database. You can give this a try, but no guarantees. If you no longer use VM Fusion then I suggest following the information below on uninstalling software.
    Rebuild LaunchServices Database
    Open the Terminal application in your Utilities folder. At the prompt paste in the following command in its entirety:
    find /System/Library/Frameworks -type f -name "lsregister" -exec {} -kill -seed -r \;
    Press RETURN.
    Wait for the Terminal prompt to return after which you can quit the Terminal.
    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash. Applications may create preference files that are stored in the /Home/Library/Preferences/ folder. Although they do nothing once you delete the associated application, they do take up some disk space. If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application. In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder. You can also check there to see if the application has created a folder. You can also delete the folder that's in the Applications Support folder. Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item. Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder. Log In Items are set in the Accounts preferences. Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab. Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS. Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term. Unfortunately Spotlight will not look in certain folders by default. You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead. Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder. Usually with the same name as the program or the developer. The item generally has a ".pkg" extension. Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are also several shareware utilities that can uninstall applications:
    AppZapper
    Automaton
    Hazel
    CleanApp
    Yank
    SuperPop
    Uninstaller
    Spring Cleaning
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • File Type Associations

    Recently re-installed Adobe Photoshop CS6, Dreamweaver CS4 and Illustrator CS4 because I had considered not renewing my Adobe CC subscription. I decided to stay on CC one more year, but the previous version installs totally messed up my default file associations. I do not want to uninstall those previous apps.
    So of course I went to Bridge preferences and painfully changed them to the CC programs. The problem is if I want to open an .ai in Photoshop CC I used to be able to from one of the options in the flyout. Now I can only pick the default and all the other options are like Photoshop CS6 and Illustrator CS4. How can I change those other options populating the flyout without uninstalling the old apps?
    I can go to Photoshop CC and manually open it there, but that defeats the whole purpose of Bridge.
    I tried to change file type associations through Windows 8 file type associations but it won't let me do it there either.
    Thanks.

    Find a file you want to have associated to a different application in the Finder.
    Control-mouse click (or right click if you have a two button mouse) the file and select Open With's submenu Other...
    Find the application you want to open it with, and make sure in the Open With... file dialog box, you check "Always Open With" before selecting the application. Documents of that type will now always open with that specific application you chose.

  • Configure File Type Associations dosen't work for users

    Hi EB,
    Does anyones knows how to set the File Type Associations for users ? It works for me when i'm logged in as Admin but not as a user. When logged as user it always ask to configure the file associations when i open JDev and even with JDev open it does not set it. I tried to find an article about that but couldn't find any.
    I'm using :
    winXP SP3
    JDeveloper 11g TP4
    and i've sets all rights for autentified users on the folders and subfolders of JDeveloper.
    Thanks

    I tried going on tool>preferences>File Type .... and associate projets and source and applications files with JDev check marking "open with JDev"... it didn't worked as user... it's just not saving my settings while reopening it it's never saved... at least i've been able to associate it in my Admin account then i can go back in user account and select open file with in windows, choose JDev and check mark "always open that file with that program" only after that the association is saved in JDev... but still it open the Configuration file windows at startup with the ones i already opened with JDev checked... anyway that's not a big issue ... only that i can't save those settings by the JDev environement while logged in as a user...

  • Restart number is not in the check file or is not a From-number

    HI!
    I had  posted  payment Document  but i  got below error while  reprint  check from  FBZ5
    Restart number is not in the check file or is not a From-number
    "Message no. FS562"
    on that base, I had  check below  settinng 
    1) I  had check  Cheque no  register . It's  proper in series.
    2)Tcd:FBZP -> Pmt methods in country -> select your country
       and payment method 'C'. If 'Bank details' is checked on, then bank
       details of vendor master is mandatory for that payment.
    Awaiting for reply soon,
    thanking you,
    Rupang shah

    Hi,
    Commonly it will come for below situations:
    1. Client decided to use this check lots for manual payment & this checks already used, so this type of checks system not allowed to take reprint.
    2. You can only reprint checks created with F110, FBZ4, F-58 or FBZ5  (this checks have been printed by the system)
    Check the Payment method wise checks it is already issued / not PAYR - RZAWE
    system not allowed to reprint already exist in PAYR table checks.
    if you already use one check with payment method C now you want to use the same lot for payment method X then system not allow to print.
    Regards,
    Viswa

  • Since changing our computer I have been unable to download ebooks to my Reader Library I get a message Some file types associated with EPUB files are not associated with Reader Library; Waterstones suggest that I may have accidentally created a new Adobe

    When I try to download them from the Waterstones website I get a message saying:
    ‘Some file types associated with EPUB files are not associated with Reader Library.  Do you want to associate them now?  When I reply yes I get another message; ‘Configuration error unable to update EPUB files check network firewall and try again’.
    The ‘books’ are saved in the Download directory and I can’t transfer them from there to my E-Reader. I have not had any problems before, it was very simple; I saved the download and it automatically went into the Reader Library.
    I contacted HP and they said it is a software error and suggested I contact Waterstones.  I contacted Waterstones Customer Support and got the following response:
    As the error message is specifically mentioning the firewall it does sound like something in the firewall settings is stopping the download from taking place correctly. However, the files should not be being saved to the Download folder. It would be worth trying again by going to your Digital Order History on your Waterstones.com account and pressing the download button, and then making sure to press "Open" not "Save". When you press Open rather than Save it should give the option to open the file with Adobe Digital Editions. If the firewall message still comes up then I'm afraid something is blocking it on your end.
    If the above "Open" download method works but you then still get an error message it could possibly be that you have accidentally created a new Adobe ID when setting up on the new computer, rather than signing in with your old Adobe ID. It would be worth trying the aforementioned download technique again first, but if problems did still persist it would be worth calling Adobe themselves on 0207 365 0735, as they should be able to sort out any account issue.
      In response to the first para of Waterstones email I already do what they suggest I do press ‘Open’ not ‘Save’ but I don’t get the open with Adobe Digital Editions (we have installed Adobe Digital Editions on the new computer. Waterstones say we may have ‘accidentally created a new Adobe ID when setting up the new computer’ does that mean that we shouldn’t have installed Adobe Digital Editions on the new computer as it would have already been there? How do I sign in with my old Adobe ID? 

    Hi all after attampting to get some supoport from adobe by phone.... nice people infurating policys as far as support for digital editions or DRM is conserned... However I got no where with support.
    I ended up instaling Digital editions on my desktop PC and going through the motions of registering and borrowing a book then returning it. Then I trying on my iPad, Bluefire worked, Over drive did not so I completely removed Overdrive and reinstalled and re registered. all working now.
    Maybe some one at adobe did something. Maybe the install of the adobe DE client on a PC corrected what ever was out of wack with my account. Mayby the server that my account lives on did a scan disk and corrected a bad clustrer.
    What ever happend My account is actiove and working again. hope this helps others.

  • FIREFOX 4 CRASHES WHEN I USE THE "BROUSE" MODE TO SELECT A PROGRAM TO OPEN A PARTICULAR FILE TYPE

    USING TOOLS-OPTIONS- APPLICATION BRINGS UP THE PANEL TO SELECT PROGRAMS FOR EACH FILE TYPE. SELECTING "USE OTHER" BRINGS ANOTHER PANEL WITH VARIOUS OPTIONS. NONE OF THESE ARE APPROPRIATE FOR MY SITUATION. AS SOON AS I CLICK "BROWSE" FIREFOX CRASHES. THE SAME THING HAPPENS IF I SELECT AN ATTACHMENT FROM AN EMAIL AND TRY TO CHANGE THE ASSOCIATED PROGRAM BY USING "BROWSE" TO FIND AN APPROPRIATE PROGRAM.

    You can uninstall (remove) the Java Console extensions and disable the Java Quick Starter extension, you do not need them to run Java applets.
    See http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    See also http://www.java.com/en/download/help/quickstarter.xml - What is Java Quick Starter (JQS)? What is the benefit of running JQS? - 6.0
    Disable the Java Quick Starter extension: Tools -> Addons -> Extensions<br />
    Control Panel -> Java -> Advanced tab -> Miscellaneous -> Java Quick Starter (disable)
    See:
    * http://kb.mozillazine.org/Firefox_crashes
    * [[Firefox crashes]]
    Create a new profile as a test to check if your current profile is causing the problems.
    See [[Basic Troubleshooting#Make_a_new_profile|Basic Troubleshooting&#58; Make a new profile]]
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins"
    If that new profile works then you can transfer some files from the old profile to that new profile (be careful not to copy corrupted files)
    See http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

Maybe you are looking for