Old 08-19-2019, 06:57 PM   #1
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 189
Default How to tell whether two files are the same one or not

For example, I have two files, D:\1.wav, E:\1.wav. Is it possible to compare them with internal or sws or JS API and tell if they are the same one or they just have a same name?
dsyrock is offline   Reply With Quote
Old 08-19-2019, 09:30 PM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,525
Default

io.open in binary mode, check content string length and some random bytes, no extension needed
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 08-19-2019, 09:39 PM   #3
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 189
Default

Quote:
Originally Posted by mpl View Post
io.open in binary mode, check content string length and some random bytes, no extension needed
Thanks mpl!
dsyrock is offline   Reply With Quote
Old 08-20-2019, 05:49 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,031
Default

Rather than compare bit per bit, just compare Checksum :P
X-Raym is offline   Reply With Quote
Old 08-20-2019, 08:53 PM   #5
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 189
Default

Quote:
Originally Posted by X-Raym View Post
Rather than compare bit per bit, just compare Checksum :P
Can you give me a little more hints about how to compare Checksum please?
dsyrock is offline   Reply With Quote
Old 08-21-2019, 01:51 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,031
Default

Use some checksum / m5 lua libraries, there is some on github


https://github.com/kikito/md5.lua


https://github.com/philanc/plc/tree/master/plc


I didn't tets it but the main idea is that it will output a unique string from a file,
so if two files are two different, it will output diffeent strings.


You only need to make a string comparison based on that.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.