GordonNT Posted July 6, 2018 Share Posted July 6, 2018 Hi, I am trying to create a script that could read a file, store its content (in a txt file for example) and then write it to a new file ? I tried this but it does not work, and strangely, the new file is bigger than the original : #include <File.au3> local $hFile = FileOpen( "C:\Users\Moi\Desktop\image.png" ) local $f = fileRead( $hFile ) _FileCreate( "C:\Users\XXX\Desktop\file\image.png" ) FileWrite("C:\Users\XXX\Desktop\file\image.png", $f) FileClose($hFile) Link to comment Share on other sites More sharing options...
xcaliber13 Posted July 6, 2018 Share Posted July 6, 2018 I could be wrong but I do believe that FileOpen will not read a .png image file. Link to comment Share on other sites More sharing options...
GordonNT Posted July 6, 2018 Author Share Posted July 6, 2018 6 minutes ago, xcaliber13 said: I could be wrong but I do believe that FileOpen will not read a .png image file. so, how am I supposed to do ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2018 Moderators Share Posted July 6, 2018 If you are using .png why are you not simply copying the file from one place to another? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
GordonNT Posted July 6, 2018 Author Share Posted July 6, 2018 5 minutes ago, JLogan3o13 said: If you are using .png why are you not simply copying the file from one place to another? I would like to transfrom the file to string, so I can store this string in a file. Then I can use this string to recreate the file Well, it's not really clear but I hope you can understand Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2018 Moderators Share Posted July 6, 2018 Nope, not a bit. What format, simple text or something else? What kind of file? To what end? Perhaps there is a better way? The more you provide the better able we are to assist: "I want to convert .png to text and then back" is a whole lot more difficult to assist with than "I want to convert an image to Base64 for use in program XYZ, then convert it back because abc". "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
GordonNT Posted July 6, 2018 Author Share Posted July 6, 2018 2 minutes ago, JLogan3o13 said: Nope, not a bit. What format, simple text or something else? What kind of file? To what end? Perhaps there is a better way? The more you provide the better able we are to assist: "I want to convert .png to text and then back" is a whole lot more difficult to assist with than "I want to convert an image to Base64 for use in program XYZ, then convert it back because abc". What i want to do is : I have a file (X) and I want to convert it to a txt one (Y) The txt file will be stored on the desktop We remove X Later, we read Y and create X Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2018 Moderators Share Posted July 6, 2018 Again, my question is what does converting it to text gain you in the scope of your process? Why not move the file, then move it back, if it will not have changed? There are plenty of threads on the forum about converting images to Base64 or some other means - try the forum search function and you will no doubt find some - although I am not aware of any for just converting to flat text. It seems wholly inefficient, hence the questions; I am willing to bet there is a better way to accomplish what you are after. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
GordonNT Posted July 6, 2018 Author Share Posted July 6, 2018 10 minutes ago, JLogan3o13 said: Again, my question is what does converting it to text gain you in the scope of your process? Why not move the file, then move it back, if it will not have changed? There are plenty of threads on the forum about converting images to Base64 or some other means - try the forum search function and you will no doubt find some - although I am not aware of any for just converting to flat text. It seems wholly inefficient, hence the questions; I am willing to bet there is a better way to accomplish what you are after. I convert to image in order to net let the picture accessible Let's say that my goal is to "hide" some pictures in a txt file I have an other question, why is my txt file (Y) is bigger than the image (X) ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2018 Moderators Share Posted July 6, 2018 For your question: (txt != image) Not sure why you would expect two different ways of representing an object to be the exact same size. For your goal, would not setting permissions on the file, setting it to hidden, or setting permissions on the folder in which it resides, be a much simpler and best practice way to accomplish your task? Any time you convert a file from one format to another and then back again you risk corruption; which requires that much more logic to accommodate those potential issues. If all you want to do is prevent/limit access, there are built-in tools for doing just that. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
GordonNT Posted July 6, 2018 Author Share Posted July 6, 2018 4 minutes ago, JLogan3o13 said: For your question: (txt != image) Not sure why you would expect two different ways of representing an object to be the exact same size. For your goal, would not setting permissions on the file, setting it to hidden, or setting permissions on the folder in which it resides, be a much simpler and best practice way to accomplish your task? Any time you convert a file from one format to another and then back again you risk corruption; which requires that much more logic to accommodate those potential issues. If all you want to do is prevent/limit access, there are built-in tools for doing just that. Thanks for all The issue with Windows permissions is that you always be able to get around them Anyways, i'll just store those images to @LocalAppDataDir and it should be ok Thanks again Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2018 Moderators Share Posted July 6, 2018 As I said, if you are dead set on converting, a quick search of the forum (or Google) will show you some threads where this has been done - although not as flat text. Good luck in your endeavors. Also, as you post in the future, please don't quote whatever the person last said. Most of us remember what we said (we were there when we said it) and it needlessly pads the thread "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
careca Posted July 8, 2018 Share Posted July 8, 2018 I did a similar thing but it was for video, and it grabs the first, say 700kb and moves them to the end of the file, and rename it without extension, so even if you give it an extension, it won't open because the file is all "messed up". If you want I can post something that is close enough to what you ask. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
careca Posted July 11, 2018 Share Posted July 11, 2018 Check this out: Inconspicuous The idea is to hide files, not full encryption so no good for sensitive data, but enough to most people not being able to figure out what the files are, more info on the page. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now