Novembre 2024 | Lun | Mar | Mer | Jeu | Ven | Sam | Dim |
---|
| | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | Calendrier |
|
|
| Infos sur un fichier | |
| | Auteur | Message |
---|
JL35
Nombre de messages : 7112 Localisation : 77 Date d'inscription : 29/11/2007
| Sujet: Infos sur un fichier Ven 10 Avr 2015 - 17:23 | |
| Suite au post de Francis-mr ci-contre qui recherchait la durée d'un fichier mp3, je viens de découvrir quelque chose d'intéressant pour obtenir toutes sortes d'infos sur un fichier, infos générales (taille, dates, etc) et infos particulières pour les fichiers images, audio, vidéo, pdf, etc. C'est une fonction système, appelée par un script vbs, donc sans faire appel à une ressource externe. Il suffit de donner à la fonction le fichier et l'indice du renseignement demandé. Cet indice est hélas variable en fonction du système (XP, W7, etc.) mais bon, comme je suis bon prince, je vous donnerai la liste piquée quelque part sur internet je ne sais plus où. Voici la sub d'appel, avec un exemple, qui renvoie le résultat dans le presse-papier (ça pourrait être dans un fichier): - Code:
-
DIM f$,index% f$ = "Z:\Page41.jpg" index% = 31: ' dimensions de l'image Infos(f$,index%) PRINT CLIPBOARD_STRING_PASTE$ END
SUB Infos(f$,index%) ' information n° index% sur le fichier f$, rendue dans le presse-papier DIM_LOCAL q$,scr$ q$ = CHR$(34) scr$ = "C:\TEMP\Infos.vbs" FILE_OPEN_WRITE 9,scr$ FILE_WRITELN 9, "FileName = "+q$+f$+q$ FILE_WRITELN 9, "with CreateObject("+q$+"Scripting.FileSystemObject"+q$+").GetFile(FileName)" FILE_WRITELN 9, " Foldername = .ParentFolder" FILE_WRITELN 9, " FileName = .Name" FILE_WRITELN 9, "End With" FILE_WRITELN 9, "with CreateObject("+q$+"Shell.Application"+q$+").Namespace(Foldername)" FILE_WRITELN 9, " wsh.echo .GetDetailsOf(.Parsename(FileName), "+STR$(index%)+")" FILE_WRITELN 9, "end with" FILE_CLOSE 9 EXECUTE_WAIT "cmd.exe /c cscript.exe "+scr$+" | clip" FILE_DELETE scr$ END_SUB Et voici la fameuse liste des infos accessibles, avec leur indice en fonction du système d'exploitation+ (c'est long, à lire avec une police fixe pour la bonne lisibilité): - Code:
-
;Attribute tables ; ; Windows 8/2012 Windows 7/2008 R2 Windows Vista/2008 Windows XP/2003 Windows 2000 ;-------------------------------------------------------------------------------------------------------------------------- ; 0 Name Name Name Name Name ; 1 Size Size Size Size Size ; 2 Item type Item type Type Type Type ; 3 Date modified Date modified Date modified Date Modified Date Modified ; 4 Date created Date created Date created Date Created Attributes ; 5 Date accessed Date accessed Date accessed Date Accessed Comment ; 6 Attributes Attributes Attributes Attributes Date Created ; 7 Offline status Offline status Offline status Status Date Accessed ; 8 Offline availability Offline availability Offline availability Owner Owner ; 9 Perceived type Perceived type Perceived type Author ??? ; 10 Owner Owner Owner Title Author ; 11 Kind Kind Kinds Subject Title ; 12 Date taken Date taken Date taken Category Subject ; 13 Contributing artists Contributing artists Artists Pages Category ; 14 Album Album Album Comments Pages ; 15 Year Year Year Copyright Copyright ; 16 Genre Genre Genre Artist Company Name ; 17 Conductors Conductors Conductors Album Title Module Desription ; 18 Tags Tags Tags Year Module Version ; 19 Rating Rating Rating Track Number Product Name ; 20 Authors Authors Authors Genre Product Version ; 21 Title Title Title Duration Sender Name ; 22 Subject Subject Subject Bit Rate Recipient Name ; 23 Categories Categories Categories Protected Recipient Number ; 24 Comments Comments Comments Camera Model Csid ; 25 Copyright Copyright Copyright Date Picture Taken Tsid ; 26 # # # Dimensions Transmission Time ; 27 Length Length Length ??? Caller Id ; 28 Bit rate Bit rate Bit rate ??? Routing ; 29 Protected Protected Protected Episode Name Audio Format ; 30 Camera model Camera model Camera model Program Description Sample Rate ; 31 Dimensions Dimensions Dimensions Description Audio Sample Size ; 32 Camera maker Camera maker Camera maker Audio sample size Channels ; 33 Company Company Company Audio sample rate Play Length ; 34 File description File description File description Channels Frame Count ; 35 Program name Program name Program name Company Frame Rate ; 36 Duration Duration Duration Description Video Sample Size ; 37 Is online Is online Is online File Version Video Compression ; 38 Is recurring Is recurring Is recurring Product Name ??? ; 39 Location Location Location Product Version ??? ; 40 Optional attendee addresses Optional attendee addresses Optional attendee addresses Keywords (XP only) ??? ; 41 Optional attendees Optional attendees Optional attendees ; 42 Organizer address Organizer address Organizer address ; 43 Organizer name Organizer name Organizer name ; 44 Reminder time Reminder time Reminder time ; 45 Required attendee addresses Required attendee addresses Required attendee addresses ; 46 Required attendees Required attendees Required attendees ; 47 Resources Resources Resources ; 48 Meeting status Meeting status Free/busy status ; 49 Free/busy status Free/busy status Total size ; 50 Total size Total size Account name ; 51 Account name Account name Computer ; 52 Task status Task status Anniversary ; 53 Computer Computer Assistant's name ; 54 Anniversary Anniversary Assistant's phone ; 55 Assistant's name Assistant's name Birthday ; 56 Assistant's phone Assistant's phone Business address ; 57 Birthday Birthday Business city ; 58 Business address Business address Business country/region ; 59 Business city Business city Business P.O. box ; 60 Business country/region Business country/region Business postal code ; 61 Business P.O. box Business P.O. box Business state or province ; 62 Business postal code Business postal code Business street ; 63 Business state or province Business state or province Business fax ; 64 Business street Business street Business home page ; 65 Business fax Business fax Business phone ; 66 Business home page Business home page Callback number ; 67 Business phone Business phone Car phone ; 68 Callback number Callback number Children ; 69 Car phone Car phone Company main phone ; 70 Children Children Department ; 71 Company main phone Company main phone E-mail Address ; 72 Department Department E-mail2 ; 73 E-mail address E-mail address E-mail3 ; 74 E-mail2 E-mail2 E-mail list ; 75 E-mail3 E-mail3 E-mail display name ; 76 E-mail list E-mail list File as ; 77 E-mail display name E-mail display name First name ; 78 File as File as Full name ; 79 First name First name Gender ; 80 Full name Full name Given name ; 81 Gender Gender Hobbies ; 82 Given name Given name Home address ; 83 Hobbies Hobbies Home city ; 84 Home address Home address Home country/region ; 85 Home city Home city Home P.O. box ; 86 Home country/region Home country/region Home postal code ; 87 Home P.O. box Home P.O. box Home state or province ; 88 Home postal code Home postal code Home street ; 89 Home state or province Home state or province Home fax ; 90 Home street Home street Home phone ; 91 Home fax Home fax IM addresses ; 92 Home phone Home phone Initials ; 93 IM addresses IM addresses Job title ; 94 Initials Initials Label ; 95 Job title Job title Last name ; 96 Label Label Mailing address ; 97 Last name Last name Middle name ; 98 Mailing address Mailing address Cell phone ; 99 Middle name Middle name Nickname ;100 Cell phone Cell phone Office location ;101 Nickname Nickname Other address ;102 Office location Office location Other city ;103 Other address Other address Other country/region ;104 Other city Other city Other P.O. box ;105 Other country/region Other country/region Other postal code ;106 Other P.O. box Other P.O. box Other state or province ;107 Other postal code Other postal code Other street ;108 Other state or province Other state or province Pager ;109 Other street Other street Personal title ;110 Pager Pager City ;111 Personal title Personal title Country/region ;112 City City P.O. box ;113 Country/region Country/region Postal code ;114 P.O. box P.O. box State or province ;115 Postal code Postal code Street ;116 State or province State or province Primary e-mail ;117 Street Street Primary phone ;118 Primary e-mail Primary e-mail Profession ;119 Primary phone Primary phone Spouse ;120 Profession Profession Suffix ;121 Spouse/Partner Spouse/Partner TTY/TTD phone ;122 Suffix Suffix Telex ;123 TTY/TTD phone TTY/TTD phone Webpage ;124 Telex Telex Status ;125 Webpage Webpage Content type ;126 Content status Content status Date acquired ;127 Content type Content type Date archived ;128 Date acquired Date acquired Date completed ;129 Date archived Date archived Date imported ;130 Date completed Date completed Client ID ;131 Device category Device category Contributors ;132 Connected Connected Content created ;133 Discovery method Discovery method Last printed ;134 Friendly name Friendly name Date last saved ;135 Local computer Local computer Division ;136 Manufacturer Manufacturer Document ID ;137 Model Model Pages ;138 Paired Paired Slides ;139 Classification Classification Total editing time ;140 Status Status Word count ;141 Status Client ID Due date ;142 Client ID Contributors End date ;143 Contributors Content created File count ;144 Content created Last printed Filename ;145 Last printed Date last saved File version ;146 Date last saved Division Flag color ;147 Division Document ID Flag status ;148 Document ID Pages Space free ;149 Pages Slides Bit depth ;150 Slides Total editing time Horizontal resolution ;151 Total editing time Word count Width ;152 Word count Due date Vertical resolution ;153 Due date End date Height ;154 End date File count Importance ;155 File count Filename Is attachment ;156 File extension File version Is deleted ;157 Filename Flag color Has flag ;158 File version Flag status Is completed ;159 Flag color Space free Incomplete ;160 Flag status Bit depth Read status ;161 Space free Horizontal resolution Shared ;162 Sharing type Width Creator ;163 Bit depth Vertical resolution Date ;164 Horizontal resolution Height Folder name ;165 Width Importance Folder path ;166 Vertical resolution Is attachment Folder ;167 Height Is deleted Participants ;168 Importance Encryption status Path ;169 Is attachment Has flag Contact names ;170 Is deleted Is completed Entry type ;171 Encryption status Incomplete Language ;172 Has flag Read status Date visited ;173 Is completed Shared Description ;174 Incomplete Creators Link status ;175 Read status Date Link target ;176 Shared Folder name URL ;177 Creators Folder path Media created ;178 Date Folder Date released ;179 Folder name Participants Encoded by ;180 Folder path Path Producers ;181 Folder By location Publisher ;182 Participants Type Subtitle ;183 Path Contact names User web URL ;184 By location Entry type Writers ;185 Type Language Attachments ;186 Contact names Date visited Bcc addresses ;187 Entry type Description Bcc names ;188 Language Link status Cc addresses ;189 Date visited Link target Cc names ;190 Description URL Conversation ID ;191 Link status Media created Date received ;192 Link target Date released Date sent ;193 URL Encoded by From addresses ;194 Media created Producers From names ;195 Date released Publisher Has attachments ;196 Encoded by Subtitle Sender address ;197 Episode number User web URL Sender name ;198 Producers Writers Store ;199 Publisher Attachments To addresses ;200 Season number Bcc addresses To do title ;201 Subtitle Bcc To names ;202 User web URL Cc addresses Mileage ;203 Writers Cc Album artist ;204 Attachments Conversation ID Beats-per-minute ;205 Bcc addresses Date received Composers ;206 Bcc Date sent Initial key ;207 Cc addresses From addresses Mood ;208 Cc From Part of set ;209 Conversation ID Has attachments Period ;210 Date received Sender address Color ;211 Date sent Sender name Parental rating ;212 From addresses Store Parental rating reason ;213 From To addresses Space used ;214 Has attachments To do title EXIF version ;215 Sender address To Event ;216 Sender name Mileage Exposure bias ;217 Store Album artist Exposure program ;218 To addresses Album ID Exposure time ;219 To do title Beats-per-minute F-stop ;220 To Composers Flash mode ;221 Mileage Initial key Focal length ;222 Album artist Part of a compilation 35mm focal length ;223 Sort album artist Mood ISO speed ;224 Album ID Part of set Lens maker ;225 Sort album Period Lens model ;226 Sort contributing artists Color Light source ;227 Beats-per-minute Parental rating Max aperture ;228 Composers Parental rating reason Metering mode ;229 Sort composer Space used Orientation ;230 Initial key EXIF version Program mode ;231 Part of a compilation Event Saturation ;232 Mood Exposure bias Subject distance ;233 Part of set Exposure program White balance ;234 Period Exposure time Priority ;235 Color F-stop Project ;236 Parental rating Flash mode Channel number ;237 Parental rating reason Focal length Episode name ;238 Space used 35mm focal length Closed captioning ;239 EXIF version ISO speed Rerun ;240 Event Lens maker SAP ;241 Exposure bias Lens model Broadcast date ;242 Exposure program Light source Program description ;243 Exposure time Max aperture Recording time ;244 F-stop Metering mode Station call sign ;245 Flash mode Orientation Station name ;246 Focal length People Auto summary ;247 35mm focal length Program mode Summary ;248 ISO speed Saturation Search ranking ;249 Lens maker Subject distance Sensitivity ;250 Lens model White balance Shared with ;251 Light source Priority Product name ;252 Max aperture Project Product version ;253 Metering mode Channel number Source ;254 Orientation Episode name Start date ;255 People Closed captioning Billing information ;256 Program mode Rerun Complete ;257 Saturation SAP Task owner ;258 Subject distance Broadcast date Total file size ;259 White balance Program description Legal trademarks ;260 Priority Recording time Video compression ;261 Project Station call sign Directors ;262 Channel number Station name Data rate ;263 Episode name Summary Frame height ;264 Closed captioning Snippets Frame rate ;265 Rerun Auto summary Frame width ;266 SAP Search ranking Total bitrate ;267 Broadcast date Sensitivity ;268 Program description Shared with ;269 Recording time Sharing status ;270 Station call sign Product name ;271 Station name Product version ;272 Summary Support link ;273 Snippets Source ;274 Auto summary Start date ;275 Search ranking Billing information ;276 Sensitivity Complete ;277 Shared with Task owner ;278 Sharing status Total file size ;279 Product name Legal trademarks ;280 Product version Video compression ;281 Support link Directors ;282 Source Data rate ;283 Start date Frame height ;284 Billing information Frame rate ;285 Complete Frame width ;286 Task owner Total bitrate ;287 Sort title Creator ;288 Total file size Encryption Level ;289 Legal trademarks Content Accessibility ;290 Video compression Document Assembly ;291 Directors Changing ;292 Data rate Commenting ;293 Frame height Copying ;294 Frame rate Form Filling ;295 Frame width Printing ;296 Video orientation Producer ;297 Total bitrate PDF Specification | |
| | | Jicehel
Nombre de messages : 5947 Age : 52 Localisation : 77500 Date d'inscription : 18/04/2011
| Sujet: Re: Infos sur un fichier Ven 10 Avr 2015 - 18:34 | |
| Impressionant, forcément à combiner avec une détection d'OS si le programme qui l'utilise est diffusé pour ne pas avoir de résultat bizzare, mais très interessant pour pas mal d'usages. | |
| | | Francis-mr
Nombre de messages : 186 Date d'inscription : 26/11/2012
| Sujet: Re: Infos sur un fichier Ven 10 Avr 2015 - 20:53 | |
| Je vois que mon interrogation a fait avancé le schmilblick | |
| | | JL35
Nombre de messages : 7112 Localisation : 77 Date d'inscription : 29/11/2007
| Sujet: Re: Infos sur un fichier Ven 10 Avr 2015 - 21:08 | |
| Ça fait toujours avancer le schmilblick de poser des questions, la preuve ! Tiens, suite à la remarque de Jicehel, une petite sub (toujours avec du vbscript, j'aime bien) pour déterminer la version de Windows du pc (rendue dans le presse_papier): - Code:
-
DIM a$ Which_OS() a$ = clipboard_string_paste$: print a$ END
SUB Which_OS() ' Déterminer la version de Windows, rendue dans le presse-papier DIM_LOCAL q$,scr$ q$ = CHR$(34) scr$ = "C:\TEMP\Script.vbs" FILE_OPEN_WRITE 9,scr$ FILE_WRITELN 9,"strComputer = "+q$+"."+q$ FILE_WRITELN 9,"Set objWMIService = GetObject("+q$+"winmgmts:"+q$+" _" FILE_WRITELN 9," & "+q$+"{impersonationLevel=impersonate}!"+q$+" _" FILE_WRITELN 9," & strComputer & "+q$+"\root\cimv2"+q$+")" FILE_WRITELN 9,"Set colOperatingSystems = objWMIService.ExecQuery _" FILE_WRITELN 9," ("+q$+"Select * from Win32_OperatingSystem"+q$+")" FILE_WRITELN 9,"For Each objOperatingSystem in colOperatingSystems" FILE_WRITELN 9," Wscript.Echo objOperatingSystem.Caption & _" FILE_WRITELN 9," "+q$+" "+q$+" & objOperatingSystem.Version" FILE_WRITELN 9,"Next" FILE_CLOSE 9 EXECUTE_WAIT "cmd.exe /c cscript.exe "+scr$+" | clip" FILE_DELETE scr$ END_SUB Pour ma part, ça renvoie: Microsoft Windows 7 Édition Familiale Premium 6.1.7601Post Scriptum je retrouve aussi dans mes archives cette sub de l'ami papydall qui a le même usage, sans vbs, peut-être sans doute préférable, ça évite de créer un fichier script: - Code:
-
SUB Windows_Ver() ' Version de Windows, -> clipboard (papydall) dim_local v$,v1$,v2$,w$,n v1$ = "version" execute_wait "cmd /c ver | clip" v$ = CLIPBOARD_STRING_PASTE$ n = instr(v$,v1$): v2$ = mid$(v$,n+8,3) if v2$ ="6.3" then w$ = "Windows 8.1" if v2$ ="6.2" then w$ = "Windows 8" if v2$ ="6.1" then w$ = "Windows 7" if v2$ ="6.0" then w$ = "Windows Vista" if v2$ ="5.1" then w$ = "Windows XP" if v2$ ="4.9" then w$ = "Windows ME" if v2$ ="5.0" then w$ = "Windows 2000" if v2$ ="4.1" then w$ = "Windows 98" if v2$ ="4.0" then w$ = "Windows 95" CLIPBOARD_STRING_COPY w$ END_SUB | |
| | | papydall
Nombre de messages : 7017 Age : 74 Localisation : Moknine (Tunisie) Entre la chaise et le clavier Date d'inscription : 03/03/2012
| Sujet: Re: Infos sur un fichier Ven 10 Avr 2015 - 21:53 | |
| Allo bon prince ! Le prince bon te parle ! Chez moi (et certainement chez d’autres) L’exécution en mode csript affiche le copyright de Microsoft sur une longue ligne et l’information utile (la version de Windows dans cet exemple) se trouve en dehors de la fenêtre du FORM 0. Voici ce que j’obtiens : (une longue ligne visible en FULL_SPACE 0) Microsoft (R) Windows Script Host Version 5.8Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés. Microsoft Windows 7 6.1.7601Pour conserver simplement l’information utile, j’ai apporté la modification suivante sur le code : - Code:
-
DIM a$ ,p,info$ Which_OS() ' a$ = clipboard_string_paste$: print a$ p = instr_pos(CLIPBOARD_STRING_PASTE$,"réservés.",1)+9 info$ = mid$(CLIPBOARD_STRING_PASTE$,p,100) print info$ END Et là, j’obtiens un bon affichage : Microsoft Windows 7 Édition Intégrale 6.1.7601A propos, bon prince: c'est une belle trouvaille que tu as faite! Merci pour le partage. | |
| | | JL35
Nombre de messages : 7112 Localisation : 77 Date d'inscription : 29/11/2007
| Sujet: Re: Infos sur un fichier Ven 10 Avr 2015 - 23:02 | |
| Comme quoi ta sub (version de Windows) est meilleure que la mienne ! mais de toute façon l'info n'est pas destinée à être affichée (ou alors dans un memo) mais exploitée par programme, et elle est bien dans la chaîne rendue. Tu peux m'appeler bon prince (charmant ?) mais ce n'est pas pour autant que je vais t'appeler la Belle au Bois Dormant D'ailleurs, à ce propos... il va être bientôt l'heure... | |
| | | Yannick
Nombre de messages : 8635 Age : 53 Localisation : Bretagne Date d'inscription : 15/02/2010
| Sujet: re Sam 11 Avr 2015 - 1:14 | |
| Merci à toute la principauté pour ces infos Celles ci valent quelques Louis...( d' or, évidemment ) | |
| | | Yannick
Nombre de messages : 8635 Age : 53 Localisation : Bretagne Date d'inscription : 15/02/2010
| Sujet: re Sam 11 Avr 2015 - 1:30 | |
| Pour que ton script Vaille un lingot, ne pourrais tu pas supprimer la fenêtre noire ?... Je ne suis pas un adepte du vbs et je n' arrive pas à combiner tes deux sub pour arriver à ce résultat... | |
| | | JL35
Nombre de messages : 7112 Localisation : 77 Date d'inscription : 29/11/2007
| Sujet: Re: Infos sur un fichier Sam 11 Avr 2015 - 14:36 | |
| Jamais contents ! C'est bien les fenêtres noires... pour dormir... Bon ygeronimi, c'est bien parce que c'est toi, mais essaie ça pour voir (avec un deuxième vbs, ça t'apprendra): - Code:
-
SUB Infos(f$,index%) ' information n° index% sur le fichier f$, rendue dans le presse-papier DIM_LOCAL a$,q$,scr$,ex$ q$ = CHR$(34) scr$ = "C:\TEMP\Infos.vbs" FILE_OPEN_WRITE 9,scr$ FILE_WRITELN 9, "FileName = "+q$+f$+q$ FILE_WRITELN 9, "with CreateObject("+q$+"Scripting.FileSystemObject"+q$+").GetFile(FileName)" FILE_WRITELN 9, " Foldername = .ParentFolder" FILE_WRITELN 9, " FileName = .Name" FILE_WRITELN 9, "End With" FILE_WRITELN 9, "with CreateObject("+q$+"Shell.Application"+q$+").Namespace(Foldername)" FILE_WRITELN 9, " wsh.echo .GetDetailsOf(.Parsename(FileName), "+STR$(index%)+")" FILE_WRITELN 9, "end with" FILE_CLOSE 9 CLIPBOARD_STRING_COPY "Null": ' réinit le clipboard, à tout hasard a$ = "cmd.exe /c cscript.exe "+scr$+" | clip" ex$ = "C:\Temp\exec.vbs" FILE_OPEN_WRITE 9, ex$: ' ===== Création du script .vbs ===== FILE_WRITELN 9, "CreateObject("+q$+"Wscript.Shell"+q$+").Run "+q$+a$+q$+",0,True" FILE_CLOSE 9 EXECUTE_WAIT "WSCRIPT.exe "+ex$: ' ===== Exécution du script ===== FILE_DELETE scr$: FILE_DELETE ex$ END_SUB En s'y connaissant bien en vbs (moi je ne fais que du bricolage) on devrait pouvoir combiner les deux en un seul, mais bon, ça marche comme ça même si ce n'est pas très optimisé. | |
| | | Yannick
Nombre de messages : 8635 Age : 53 Localisation : Bretagne Date d'inscription : 15/02/2010
| Sujet: re Sam 11 Avr 2015 - 18:36 | |
| Merci JL35, je ne demande qu' à apprendre... | |
| | | Contenu sponsorisé
| Sujet: Re: Infos sur un fichier | |
| |
| | | | Infos sur un fichier | |
|
Sujets similaires | |
|
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |